-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update proxy logic to handle cors when single url config is used
- Loading branch information
1 parent
ce15b65
commit 80dfd3d
Showing
11 changed files
with
226 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from haupt import settings | ||
from haupt.proxies.schemas.base import get_config | ||
|
||
CORS_OPTIONS = r""" | ||
if ($request_method = 'OPTIONS') {{ | ||
add_header 'Access-Control-Allow-Origin' "$http_origin" always; | ||
add_header 'Access-Control-Allow-Credentials' 'true' always; | ||
add_header 'Access-Control-Allow-Headers' 'X-POLYAXON-SERVICE,x-csrftoken,X-CSRF-Token,Authorization,Accept,Origin,DNT,X-Mx-ReqToken,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Sec-Fetch-Mode,User-Agent' always; | ||
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always; | ||
add_header 'Access-Control-Max-Age' 1728000 always; | ||
add_header 'Content-Length' 0; | ||
add_header 'Content-Type' 'text/plain; charset=utf-8'; | ||
return 204; | ||
}} | ||
add_header 'Access-Control-Allow-Origin' "$http_origin" always; | ||
add_header 'Access-Control-Allow-Credentials' 'true' always; | ||
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always; | ||
add_header 'Access-Control-Allow-Headers' 'X-POLYAXON-SERVICE,x-csrftoken,X-CSRF-Token,Authorization,Accept,Origin,DNT,X-Mx-ReqToken,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Sec-Fetch-Mode,User-Agent' always; | ||
""" # noqa | ||
|
||
|
||
def get_cors_config(): | ||
return get_config( | ||
options=CORS_OPTIONS if settings.PROXIES_CONFIG.ui_single_url else "", | ||
indent=0, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.