0

I want to deploy my nextjs app to my server. i started server with "npm run start". it runs on localhost:3000. Then I proxypass localhost:3000 to domain of my website. I edited apache conf file like this:

enter image description here

and now when i go to my website from my domain I'm getting a lot of errors in console and app doesnt work well. functionality breaks. it fails to load chunks and show me in console "is true hostaname: false". I don't know what to do now. help, plz.

Barak
  • 1,390
  • 15
  • 27
OlegKusov
  • 43
  • 3

1 Answers1

0

Pay attention there are many 404 on js files. enter image description here

You need to add a mapping between _next/static -> .next/static folder.

felixmosh
  • 32,615
  • 9
  • 69
  • 88
  • hm. Thank you. I will try and give you feedback – OlegKusov Feb 23 '20 at 22:14
  • 2
    I added "distDir: '_next' in next config file and it helped. Thanks. – OlegKusov Feb 23 '20 at 23:19
  • I've ran into the same issue but don't fully understand your response, please can you give an example? – Hussein Duvigneau Jan 04 '22 at 02:50
  • try @OlegKusov solution, in your `next.config.js` file make the `distDir: '_next'` – felixmosh Jan 04 '22 at 07:41
  • ah my bad, I'm having this issue with HMR on dev, not with the build. My 404 is on `GET wss://[my-proxy-domain]/_next/webpack-hmr`. Also using apache. if you have any ideas, ty – Hussein Duvigneau Jan 04 '22 at 15:51
  • It is related to the websocket that Next.js started to use, you need to proxy it as well. https://stackoverflow.com/questions/27526281/websockets-and-apache-proxy-how-to-configure-mod-proxy-wstunnel#answer-27534443 – felixmosh Jan 05 '22 at 09:12