Skip to content

Commit 7a8fe03

Browse files
authored
Merge pull request #10 from pythonkr/fix/relieve-cors
fix: CORS 제약 조건을 완화
2 parents 3210e8f + 1914d2c commit 7a8fe03

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

app/core/settings.py

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import typing
66

77
import boto3
8+
import corsheaders.defaults
89
import environ
910
import sentry_sdk
1011
import sentry_sdk.integrations.aws_lambda
@@ -111,38 +112,18 @@
111112
# CORS Settings
112113
# pycon domain regex pattern
113114
CORS_ALLOWED_ORIGIN_REGEXES = [
114-
r"^https://\w+\.pycon\.kr$",
115-
r"^http://\w+\.pycon\.kr$",
116-
r"^https://\w+\.dev.pycon\.kr$",
117-
r"^http://\w+\.dev.pycon\.kr$",
118-
r"http://localhost:\d+$",
119-
r"https://localhost:\d+$",
120-
r"http://127.0.0.1:\d+$",
121-
r"https://127.0.0.1:\d+$",
115+
r"^(http|https):\/\/([a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.pycon\.kr)$", # pycon.kr 하위 도메인
116+
r"^(http|https):\/\/(localhost|127\.\d{1,3}\.\d{1,3}\.\d{1,3})(:\d{1,5})?$", # 로컬 환경
122117
]
123-
124118
CORS_ALLOWED_ORIGINS = [
125-
"https://pycon.kr",
126-
"https://2025.pycon.kr",
127-
"http://pycon.kr",
128-
"http://2025.pycon.kr",
119+
f"{protocol}://{domain}{port}"
120+
for protocol in ("http", "https")
121+
for domain in ("localhost", "127.0.0.1", "pycon.kr", "local.dev.pycon.kr")
122+
for port in ("", ":3000", ":5173")
129123
]
130-
131-
if DEBUG:
132-
CORS_ALLOWED_ORIGIN_REGEXES += []
133-
134124
CORS_ALLOW_CREDENTIALS = True
135-
136-
CORS_ALLOW_HEADERS = [
137-
"authorization",
138-
"content-type",
139-
"x-csrftoken",
140-
"accept",
141-
"accept-encoding",
142-
"origin",
143-
"user-agent",
144-
"x-requested-with",
145-
]
125+
CORS_ALLOW_HEADERS = [*corsheaders.defaults.default_headers, "accept-encoding", "origin", "x-csrftoken"]
126+
SECURE_CROSS_ORIGIN_OPENER_POLICY = None if DEBUG else "same-origin"
146127

147128
# Application definition
148129

0 commit comments

Comments
 (0)