A
A
Al2019-04-18 12:41:04
Nginx
Al, 2019-04-18 12:41:04

How to change the response from the server?

Is it possible somehow to change the response from the server without making a redirect?
Let's say everything that starts with /api is sent to the backend

location /api {		
    rewrite ^/(.*)/$ /$1 permanent;
    proxy_pass https://127.0.0.1:9909;
  }

For everything else, specify the statics:
location / {	
    root C:/client;
  }

But what if the url is /articles or /auth? You need to somehow give the contents of the C:/client/index.html file, while not making a redirect. How to do it?
Would it be wrong to use error_page for this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-04-18
@dodo512

root C:/client;
rewrite ^/(articles|auth)$ /index.html;

Or
root C:/client;
location ~ ^/(articles|auth)$ {
    try_files /index.html =404;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question