|
5 | 5 | import typing |
6 | 6 |
|
7 | 7 | import boto3 |
| 8 | +import corsheaders.defaults |
8 | 9 | import environ |
9 | 10 | import sentry_sdk |
10 | 11 | import sentry_sdk.integrations.aws_lambda |
|
111 | 112 | # CORS Settings |
112 | 113 | # pycon domain regex pattern |
113 | 114 | 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})?$", # 로컬 환경 |
122 | 117 | ] |
123 | | - |
124 | 118 | 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") |
129 | 123 | ] |
130 | | - |
131 | | -if DEBUG: |
132 | | - CORS_ALLOWED_ORIGIN_REGEXES += [] |
133 | | - |
134 | 124 | 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" |
146 | 127 |
|
147 | 128 | # Application definition |
148 | 129 |
|
|
0 commit comments