Sitelet https://github.com/angular/angular/issues/38194
Skip to content

Angular Service worker incorrectly intercepting http redirects (302) #38194

Description

@kaizen-bzh

Hello,

i work on with angular pwa project with spring-boot back end.

In my project, i am using Angular and Spring boot. My service worker is generating by Angular when i build my project.

I use external service (auth2) and my back-end redirecting to login page when session times out. This works perfectly fine without the service worker enabled, however with the service worker this fails.

To my observation, the mode of the Request is changed from navigate to cors. i see that in request headers

Without SW:

Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate

With SW:

Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors

When active service worker, i have this exception :

Access to fetch at 'https://authentication-url.com/...' (redirected from 'https://my-w ebsite.com/file-request.json') from origin 'https://my-website.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I tried adding ngsw-bypass=true query param to the redirect, but that did not help.

Can you help me ? I search on web but i found nothing on this problem with Angular service worker.

🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: service-workerIssues related to the @angular/service-worker packageneeds reproductionThis issue needs a reproduction in order for the team to investigate furthertype: bug/fix

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions