Nginx not serving a NEXT JS 13 route
Unanswered
Oak Titmouse posted this in #help-forum
Oak TitmouseOP
I have deployed my next js website on Aws ec2 and I am using Nginx to reverse proxy the request to port 3000. This setup works, But what i want is not to serve the home page but a particular page. Here is my Nginx conf which works:
But I want to serve another page eg: http://localhost:3000/myPage here is the conf for this:
This does not work it shows a white blank page and in the console there are some errors like this
I want to know can this work? and if it is not working then what is the reason? Also I do know that we can rewrite in next for this kind of work but I am just curious why is this happening???
server {
server_name mydomainname;
proxy_connect_timeout 5m;
proxy_send_timeout 30m;
proxy_read_timeout 30m;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; }
}But I want to serve another page eg: http://localhost:3000/myPage here is the conf for this:
server {
server_name mydomainname;
proxy_connect_timeout 5m;
proxy_send_timeout 30m;
proxy_read_timeout 30m;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://localhost:3000/myPage;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; }
}This does not work it shows a white blank page and in the console there are some errors like this
Uncaught SyntaxError: Unexpected token '<'I want to know can this work? and if it is not working then what is the reason? Also I do know that we can rewrite in next for this kind of work but I am just curious why is this happening???
3 Replies
Asian paper wasp
Do you make a fetch request?
An invalid response should be causing this
Oak TitmouseOP
i don't think fetch requests are causing an issue. Even if i serve a completely static page without any api calls it still doesn't work