Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
320 stars 53 forks source link

web app manifest 302 redirects to protected branch auth page, when the environment is protected? #1279

Open zola-25 opened 10 months ago

zola-25 commented 10 months ago

Describe the bug

Steps to reproduce the behavior:

  1. Set a protected environment:
image image
  1. Login

  2. Error in devtools:

    image
  3. Notice when loading resources, web manifest is loaded from static web app server with 302, from a different IP to other resources?

    image
  4. The app manifest content has become the HTML of the standard auth page of the protected branch!:

    image

Expected behavior web app manifest should load as any other resource on a protected branch, post-auth, with response 200 with the content that was set at build/deploy time.

When branch is not protected, the behaviour is normal (as expected). manifest file loads with no redirect and with the content that was set by development.

Additional context Web app is a pre-compiled Blazor web assembly app, with both app build and api build skipped by Oryx.

milton-imageline commented 5 months ago

Same problem here, any solution?

milton-imageline commented 5 months ago

@zola-25 Ok, found the solution: if you are using Vite PWA, you need to explicitly tell it to send the credentials for the manifest (I didn't see this in their docs, but I found it checking the code):

export default defineConfig({
 // your vite config
 plugins: [
        VitePWA({
            // your config
            useCredentials: true,
        }),
        // the rest of your plugins
  ]
})  

Hope it helps!