Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Request URLs Open in New Tab Redirect to 404 Page #136

Closed
IShinji opened this issue May 21, 2024 · 2 comments
Closed

API Request URLs Open in New Tab Redirect to 404 Page #136

IShinji opened this issue May 21, 2024 · 2 comments

Comments

@IShinji
Copy link

IShinji commented May 21, 2024

I am using Nuxt.js for my project and I have encountered an issue where opening API request URLs in a new tab results in a 404 page. It appears that the service worker (SW) is intercepting the routing. However, if I perform a hard refresh, the page correctly returns the JSON data from the API.

Steps to reproduce:

  1. Open an API request URL in a new tab.
  2. Observe the 404 error page.
  3. Perform a hard refresh on the new tab.
  4. Observe the correct JSON data being returned.

Expected behavior:
When opening an API request URL in a new tab, it should directly return the JSON data without needing a hard refresh.

Current behavior:
Opening an API request URL in a new tab results in a 404 page until a hard refresh is performed.

Possible cause:
It seems the service worker might be intercepting the route and causing the 404 page issue.

How to fix:
Looking for suggestions on how to prevent the service worker from intercepting API request URLs or any other potential fixes for this issue.

Environment:
Nuxt.js version: 3.11.2
Browser: Chrome 124.0.6367.209
Operating System: MacOS 14.5
Thank you for your help!

@IShinji IShinji closed this as completed May 21, 2024
@IShinji IShinji reopened this May 21, 2024
@userquin
Copy link
Member

userquin commented May 21, 2024

You must:

  • add all api calls and ssr pages to navigateFallbackDenylist regex array
  • include a runtime caching with NetworkFirst o NetworkOnly strategy for those api calls and ssr pages with the handleDidError redirecting to the navigateFallback (or any other pages/url being precached)

Check this issue vite-pwa/sveltekit#65

@IShinji
Copy link
Author

IShinji commented May 22, 2024

You must:

  • add all api calls and ssr pages to navigateFallbackDenylist regex array
  • include a runtime caching with NetworkFirst o NetworkOnly strategy for those api calls and ssr pages with the handleDidError redirecting to the navigateFallback (or any other pages/url being precached)

Check this issue vite-pwa/sveltekit#65

Thank you for the solution! I've implemented the changes based on your suggestions, and the issue is now resolved. Appreciate your help!

@IShinji IShinji closed this as completed May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants