Friday 27 March 2020

Express and Nginx figthing over routing ?

So i have a strange configuration that i need until i get to refactor a project later this year.it is a static index.html landing page served with a location root "/" by NGINX.i have a slash location:​```location /channel/ { proxy_pass http://node_server_channel:5000/; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_set_header X-Ssl on; proxy_cache_bypass $http_upgrade; } ```that express.js then handles. Express just serves a static folder with auto-generated content that a user can then navigate around in.It works well in the sense that any appending slashes like:/channel/open/but ONLY if i have a trailing slash after "open". If i leave it out then NGINX will throw a "404 Not Found", if i keep it in, it works as intended.The thing is that a user should be able to click on a folder in the static served directory to traverse a file structure, and the way that works in a browser is that it does not append a trailing slash to a directory name when clicked, so NGINX then throws the "404".I have tried a NPM package called 'express-slash' but that did not solve the issue.i was hoping someone here had some suggestions on what i could try out next?

Submitted March 27, 2020 at 07:53AM by 5t4iN

No comments:

Post a Comment