Report this

What is the reason for this report?

Issue in proxy pass from nginx to angular application

Posted on May 7, 2021

I have created an angular application that displays a page with “Hello World” on ‘/hello’ route. url for angular: http://localhost:4200/hello When I make request from browser to nginx on ‘/greet’: http://localhost/greet that should be redirected to /hello route of angular application so that the page with “Hello World” is displayed. But if the request is http://localhost/hello , an err should appear

The nginx conf:

server {
listen 80;
server_name _;
location /greet {
proxy_pass http://localhost:4200/hello;
}
location /hello {
return 404;
}
}

The issue is that while redirecting, the route is not getting modified as ‘/hello’ And since there is no ‘/greet’ route in angular, we get a not found.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.