TP-46224 | nginx configuered to handle cors

This commit is contained in:
AyushRanjan
2023-11-15 16:34:16 +05:30
parent 7eb1520496
commit 7fbb081946
3 changed files with 27 additions and 1 deletions

View File

@@ -8,5 +8,7 @@ sed -i "s~<DISABLE_UNIVERSAL_AUTH>~${DISABLE_UNIVERSAL_AUTH}~g" /usr/share/nginx
sed -i "s~CSP_HEADER~${CSP_HEADER}~g" /etc/nginx/conf.d/nginx.conf
sed -i "s~<TABLEAU_SERVER_URL>~${TABLEAU_SERVER_URL}~g" /usr/share/nginx/html/config.js
sed -i "s~<JANUS_API_URL>~${JANUS_API_URL}~g" /usr/share/nginx/html/config.js
sed -i "s~JANUS_API_URL~${JANUS_API_URL}~g" /etc/nginx/conf.d/nginx.conf
sed -i "s~VPC_NAMESERVER~${VPC_NAMESERVER}~g" /etc/nginx/conf.d/nginx.conf
exec "$@"

View File

@@ -1,6 +1,7 @@
server {
listen 8080;
client_max_body_size 100M;
resolver VPC_NAMESERVER;
set $csp_header CSP_HEADER;
add_header Content-Security-Policy $csp_header;
@@ -10,6 +11,29 @@ server {
gzip_comp_level 4;
gzip_types text/css application/javascript;
location ~ ^/events$ {
proxy_ssl_server_name on;
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Methods 'DELETE, GET, OPTIONS, PATCH, POST, PUT';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Realm-Id,X-Session-Token, X-Channel, Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header Content-Type text/plain;
add_header Content-Length 0;
return 204;
}
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Methods 'DELETE, GET, OPTIONS, PATCH, POST, PUT';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Realm-Id,X-Session-Token, X-Channel, Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
set $config_service_base_url JANUS_API_URL;
proxy_read_timeout 120;
proxy_next_upstream error;
proxy_pass $config_service_base_url/events/json$1$is_args$args;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;

View File

@@ -1 +1 @@
export const JANUS_API = `${window?.config?.JANUS_API_URL}/events/json`;
export const JANUS_API = `/events`;