I need to be able to return a valid JSON response with no HTML wrapping it all. I can accomplish this by specifying a port number pointing directly to my Express backend but need to be able to return pure JSON without having to specify a port number in production. Is there any way to do this if you're using React/React-Router and Express together?
This setup uses a proxy pass to work:
server {
listen 80;
listen [::]:80;
server_name example.com;
location / {
proxy_pass http://localhost:5000;
}
}
Current output: https://socialmaya.com/u/real (1)
Desired output: http://socialmaya.com:5000/actors/real (2)
So I need the output of 1 to be the exact same as 2, ensuring that another server can read it. If you click to View Page Source for both, you can see that the output is not the same.
/u/realvs/actors/realthat introduces the JSON vs HTML? It has nothing to do withhttpsvs port 5000./actors/realvia port 5000 is that Express is listening on that port. If I attempt to access that URI viahttpsand without specifying a port number, React/React-Router renders a 404 page. I'm not sure but it seems like React-Router is blocking any access to Express routes unless they're being called within a component./u/realto/actors/realbefore passing it upstream? Tryrewrite ^/u/(.*)$ /actors/$1 last;