skip to Main Content

I made a sample application that produces dynamic static files. I basically do not want to enter all the routes manually into the default file of Nginx. I saw some solutions here but the answers were not understandable for me in my simple case.

So basically my structure looks like this :

the main link of the application:

https://mysite.come/myproject/products

dynamic routes are numbers that also the link has query string
for example:

https://mysite.come/myproject/products/1?rand=something
https://mysite.come/myproject/products/2?rand=something
https://mysite.come/myproject/products/3?rand=something
https://mysite.come/myproject/products/4?rand=something

I could basically write :

 location /myproject/products/1/ {
      proxy_pass http://localhost:8000/1;
   }

and need to repeat this for all the products which are none sense. Is there any way to do it automatically?

when I use dev mode ( npm run dev) I get

2

Answers


  1. maybe using try_files? see the last part of this article

    Login or Signup to reply.
  2. location /myproject/products/ {
        proxy_pass http://localhost:8000;
    }
    
    server {
        listen       8000;
        server_name  localhost;
        location / {
            root   path_of_web_bundle;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search