From c37a1d4ac3df9550c3e90b19c71e8c34c9e53876 Mon Sep 17 00:00:00 2001 From: Saurabh Shrihar Date: Mon, 8 Apr 2024 21:33:22 +0400 Subject: [PATCH 1/2] Test an nginx config --- .github/workflows/build_and_deploy.yml | 2 +- .github/workflows/deployment.yml | 4 +++- nginx.conf | 11 +++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index d1138a8..32da318 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -8,7 +8,7 @@ on: jobs: deploy_workflow: - name: Deploy static + name: Deploy static ${{ inputs.environment }} permissions: id-token: write contents: write diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 8eb9082..a6b06e8 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -3,6 +3,7 @@ on: push: branches: - master + - DEVOPS-2599-cors-issue-update workflow_dispatch: inputs: environment: @@ -17,5 +18,6 @@ jobs: deploy: uses: ./.github/workflows/build_and_deploy.yml with: - environment: ${{ inputs.environment || 'dev' }} + environment: "staging" + # environment: ${{ inputs.environment || 'dev' }} secrets: inherit diff --git a/nginx.conf b/nginx.conf index 8191d85..2a4fdfd 100644 --- a/nginx.conf +++ b/nginx.conf @@ -7,11 +7,14 @@ server { location / { try_files $uri $uri/ /index.html =404; add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; # Update to include OPTIONS method + add_header Access-Control-Allow-Headers "Authorization, Content-Type"; # Specify allowed headers + add_header Access-Control-Max-Age 86400; # Set CORS preflight request cache duration add_header Access-Control-Allow-Credentials false; - add_header Access-Control-Allow-Headers *; - add_header Access-Control-Allow-Methods GET; - add_header Access-Control-Allow-Methods POST; - add_header Access-Control-Allow-Methods OPTIONS; add_header Access-Control-Expose-Headers *; + + if ($request_method = 'OPTIONS') { + return 204; # Return 204 No Content for OPTIONS requests + } } } From f1c885356f51fab6d6118306a38531ccf0177576 Mon Sep 17 00:00:00 2001 From: Saurabh Shrihar Date: Mon, 8 Apr 2024 21:39:17 +0400 Subject: [PATCH 2/2] Fix for cors issue with static app --- .github/workflows/deployment.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index a6b06e8..8eb9082 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -3,7 +3,6 @@ on: push: branches: - master - - DEVOPS-2599-cors-issue-update workflow_dispatch: inputs: environment: @@ -18,6 +17,5 @@ jobs: deploy: uses: ./.github/workflows/build_and_deploy.yml with: - environment: "staging" - # environment: ${{ inputs.environment || 'dev' }} + environment: ${{ inputs.environment || 'dev' }} secrets: inherit