Next.js Discord

Discord Forum

Not sure why context.params from SSR returns sw.js

Unanswered
Whimbrel posted this in #help-forum
Open in Discord
Avatar
WhimbrelOP
Do you know why getServerSideProps returns sw.js from context.params?
Image

24 Replies

Avatar
WhimbrelOP
As a workaround I did this:
  if (slug === "sw.js") {
    return { props: {} }; // Return empty props or handle as needed
  }
Image
Avatar
Ray
Avatar
WhimbrelOP
Hi @Ray hope you're doing well.
Do you have the same problem? Seems like this is a common issue..
Avatar
Ray
nope
have you tried other browser?
or try start the server with different port
PORT=4000 npm run dev
Avatar
Ray
probably you have server worker registered with other app with same url. check your dev tool
Image
Avatar
WhimbrelOP
I've tried also other browser, same issue:
Image
I've tried Firefox + Chrome.
with npm run build && npm run start
Avatar
Ray
have you checked here?
Avatar
WhimbrelOP
hmm, with port:4000 seems to not happen anymore.
Avatar
Ray
look like this is the reason
Avatar
WhimbrelOP
Image
This service worker helps the browser to serve the page faster and cache the content?
Avatar
Ray
unregister it
only if you have implemented service worker for your app
like pwa
or you can just ignore the error
Avatar
WhimbrelOP
aa, yea, I've installed pwa on other app, probably that's why I found that sw.js.
Thank you very much :). Now I know what to do.
Avatar
Ray
np