Score:0

A frontend app redirection to backend using nginx does not work

co flag

I have a React app with an nginx conf as below. This app communicates with a backend (represented here with the alias app-backend in the conf file).

upstream app-backend {
    server app-backend.domain.com;
}

server {
    listen 3000;
    root /usr/share/nginx/html;
    location /api/ {
        proxy_pass https://app-backend/;
        proxy_redirect default;
    }
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

In the React app, when a user clicks the login button, this code is executed:

      window.location.replace('/api/auth/login');
      return false;

Redirection to the backend does not work though; in the frontend, I get a 404 Not Found nginx/1.17.8 and the frontend UTL changes to app-frontend.domain.com/api/auth/login

By the way, when I test this locally, redirection to my backend is successful, and the authorization server is called as well.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.