I'm trying to pass the API requests to the backend with NGINX reverse proxy.
When I send a get request to /api/testdata, it sends a request to {frontendURL}/api/testData which returns with 301(redirect) status code. After that It redirects the request to the correct url {backendURL}/api/testData.
Network tab network tab 1 network tab 2 network tab 3
nginx config:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /usr/share/nginx/html;
server_name _;
location /health {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 '{"status":"Healthy"}';
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /api {
proxy_pass http://localhost:3001;
proxy_redirect off;
}
Can I somehow prevent the redirect request so that only one request goes out? Or is this the normal behaviour?