Next.js application is looking for wrong "_next" directory after build & start #11622
Replies: 5 comments 12 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Guys, I've fixed the error. My server is running with Nginx, so I change the Nginx conf file of the domain. If anyone else has this problem I fixed adding this code:
Now the system is loading the correct path when accessing the page. Thanks. |
Beta Was this translation helpful? Give feedback.
-
I had the exact same issue ! I tried everything nothing worked but in the nginx config file i removed the line " try_files $uri $uri/ =404 " inside location / { } and the problem was fixed. |
Beta Was this translation helpful? Give feedback.
-
This is the nginx config that fixed it for me: Also wrote a blog post featuring the topic: |
Beta Was this translation helpful? Give feedback.
-
When Dockerizing the Next.js frontend application, I encountered a similar error:
This occurs because:
Solution: Add the following line to the file:
This instructs Docker to ignore the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm running build & start with my Next.js application on my own server. The page content (HTML tags and text) is loading fine but nothing else loads (css, js etc). When I go to the console all the assets are returning 404 error because it's trying to search for a directory which doesn't exist, for example:
https://mywebsite.com/_next/static/css/styles.a95cabed.chunk.css
But the problem is that _next doesn't exist on my server, I can see only .next directory. Why the build is generating different directories? Sorry if it's a newbie issue, I'm still learning React & Next.js. Locally everything works fine.
Thank you!
System information
Both my laptop and server are Ubuntu 18.04
"dependencies": {
"@tanem/react-nprogress": "^3.0.19",
"@zeit/next-sass": "^1.0.1",
"leaflet": "^1.6.0",
"next": "9.2.2",
"next-i18next": "^4.2.0",
"node-sass": "^4.13.1",
"react": "16.12.0",
"react-dom": "16.12.0",
"react-icons": "^3.9.0",
"react-leaflet": "^2.6.3",
"react-reveal": "^1.2.2"
}
UPDATE:
I will try to describe the steps I'm taking:
1 - The directory on my server is empty
2 - I upload the following files/directories from my PC:
package.json
i18n.js
yarn.lock
next.config.js
server.js
/pages
/styles
/components
/lib
/contexts
/public
3 - On my server I run the command "yarn" to download the packages
4 - I run "yarn build" (next build)
5 - Then "yarn start" (NODE_ENV=production node server.js)
6 - "Ready on http://localhost:3000" is displayed on the console, in my server the port 3000 is used proxy (Nginx) pointing to the test domain I'm using: https://node.alexandrepaiva.dev
7 - No asset is loaded (You can see the browser console error) - Because it's trying to load from the directory that doesn't exist (that I explained originally on the post)
Note: locally everything works fine
I'd like to know what I'm doing wrong and what to do to fix it?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions