Nodejs Express Api Only Returns Index.html File On Production?
My original question: How to set up VueJS routes and NodeJS Express API routes? I got feedback that if Serving VueJS Builds via Express.js using history mode question doesn't solve
Solution 1:
I ended up placing all API
endpoints under /api
prefix and changed the Nginx configs to be something like this:
location / {
try_files $uri $uri/ /index.html;
location /api {
proxy_pass http://localhost:1234;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
So, now using /api/user
instead of /user
works as expected. Doesn't return the index.html
file anymore.
Post a Comment for "Nodejs Express Api Only Returns Index.html File On Production?"