Compare commits

...

2 Commits

Author SHA1 Message Date
fe9caeb09a Merge pull request '[🐛] 헤더 관련 로직 수정' (#53) from seonkyu.kim/AcaMate_API:main into debug
All checks were successful
Back/pipeline/head This commit looks good
Reviewed-on: https://git.ipstein.myds.me/AcaMate/AcaMate_API/pulls/53
2025-06-18 03:55:24 +00:00
6c8c9972b2 [🐛] 헤더 관련 로직 수정
1. 순서 변경
2. 주석 정리
2025-06-18 12:54:02 +09:00
2 changed files with 10 additions and 5 deletions

View File

@ -213,9 +213,6 @@ else
// 로컬 테스트 위한 부분 (올릴떄는 켜두기) // 로컬 테스트 위한 부분 (올릴떄는 켜두기)
app.UseHttpsRedirection(); app.UseHttpsRedirection();
// 헤더 미들웨어 부분
app.UseMiddleware<APIHeaderMiddleware>
((object)new string[] { "iOS_AM_Connect_Key", "And_AM_Connect_Key", "Web_AM_Connect_Key" });
app.UseStaticFiles(new StaticFileOptions app.UseStaticFiles(new StaticFileOptions
{ {
@ -229,6 +226,13 @@ app.UseCors("CorsPolicy");
app.UseAuthentication(); app.UseAuthentication();
app.UseAuthorization(); app.UseAuthorization();
// 헤더 미들웨어 부분
app.UseMiddleware<APIHeaderMiddleware>
((object)new string[] { "iOS_AM_Connect_Key", "And_AM_Connect_Key", "Web_AM_Connect_Key" });
app.UseWebSockets(); app.UseWebSockets();
Console.WriteLine($"[정적 파일 경로] {staticRoot}"); Console.WriteLine($"[정적 파일 경로] {staticRoot}");
app.UseEndpoints(end => app.UseEndpoints(end =>

View File

@ -34,6 +34,7 @@ namespace Back.Program.Common.Auth
// 정적 파일 요청은 미들웨어 건너뜀 // 정적 파일 요청은 미들웨어 건너뜀
var path = context.Request.Path.Value; var path = context.Request.Path.Value;
if (path != null && (path.StartsWith("/api"))) if (path != null && (path.StartsWith("/api")))
{ {
// Scoped 사용해서 값 가져오는 곳임 // Scoped 사용해서 값 가져오는 곳임
@ -43,8 +44,8 @@ namespace Back.Program.Common.Auth
foreach (var header in _headerNames) foreach (var header in _headerNames)
{ {
/// context.Request.Headers.TryGetValue(header, out var headerValue) // context.Request.Headers.TryGetValue(header, out var headerValue)
/// header 를 찾는데 header // header 를 찾는데 header
if (context.Request.Headers.TryGetValue(header, out var headerValue) && if (context.Request.Headers.TryGetValue(header, out var headerValue) &&
!string.IsNullOrWhiteSpace(headerValue)) !string.IsNullOrWhiteSpace(headerValue))
{ {