Newbie to nodejs.
I have a an API folder - whenever the server get an API request - it should execute the function binded to that route.
However - whenever there is a non-API request, I want the nodejs
server serve the static files so that the angular app will "take responsibility" and show the relevant components. This is mainly reflected when I do a refresh (F5) when I'm in one of the angular component.
Here is my nodejs
relevant code:
app.use("/api", require("./api/v1")); // This should take care in every API request
My static files located (after deploy) under /site/public/dist/public/
and there is an index.html there with a <base href="<app root location>">
.
To make things simple - I would like my application (after build to prod) to manage to make a refresh and reach the same component without the "cannot get" error
This is what I've already tried to do, not much of success:
app.use('/', express.static(__dirname +'/site/public/dist/public/', { redirect: false }));
app.use('*', (req, res) =>
{
res.sendFile(__dirname +'/site/public/dist/public/');
});