2

I have an angular app thet is served by node.

I've configured nginx to serve node on the root route "/". Then I configured a secend location for another api on the route "/api".

Now when I open the browser for the first time and I try to get "/api" it works perfectly. But if I open the angular app first and then I try to get "/api". angular (or node) is trying to handle the "/api" route so I can't get the "/api" route.

Here is my nginx location configuration.

location /api {
    # some api
    proxy_pass http://127.0.0.1:5984/;
}

location / {
    # node angular app
    proxy_pass http://localhost:3000;
}

Here is my node configuration

const express = require('express');
const http = require('http');
const path = require('path');
const compression = require("compression");

const app = express();

const port = '127.0.0.1:3000';
app.use(compression());
app.use(express.static(__dirname));

app.get('/*', (req, res) => res.sendFile(path.join(__dirname)));

const server = http.createServer(app);

server.listen(3000, "127.0.0.1", () => console.log('App is running'));

UPDATE

After testing in windows it looks like there is no problem there.

It looks like an safari bug.

I was testing on safari and chrome for mac.

0 Answers0