[🐛] 헤더 관련 로직 수정

1. 순서 변경
2. 주석 정리
This commit is contained in:
SEAN-59 2025-06-18 12:54:02 +09:00
parent 2766b3489d
commit 6c8c9972b2
2 changed files with 10 additions and 5 deletions

View File

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

View File

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