Next.js Discord

Discord Forum

Error 404 when loading static js

Answered
GabrieleAGenius posted this in #help-forum
Open in Discord
So, you know the JS files that nextjs creates and loads on its own to load stuff in your page? Exactly.
MY nextjs, is just too lazy. I've tried to build the code multiple times, it just, doesn't.
I'll explain better for you:

There is the header component, that for mobile loads the website title + a Burger button to load the menu. It uses useState from React, that changes a class inside the menu to make it toggle when you click the button. The issue is... In the index.tsx it works ok (but it still gives this error in console), but in /view/[id].tsx (its a blog) the button doesnt work.
If you look at the attachments there is an image showing the errors, and you can notice that in the middle of the URL there's a /view/, so it means its a js file related to /view/[id].tsx i guess(?)
I also uploaded a video showing how in mobile view the button doesn't work in a page, but it does in another.

Do you want to know the funniest part? HOSTING LOCALLY, IT WORKS!!!
I mean, both on development build and production build, there's no issue from my computer.
But when I run the production build from my VPS, it just f**ks everything up.
I searched on internet for similar errors, on stackoverflow and other forums, but nothing came up.
I'm desperate, help me before I thow something...
Answered by GabrieleAGenius
fixed with next.js 14
View full answer

2 Replies

btw I'm using Pages Routing
fixed with next.js 14
Answer