I am a junior dev so I apologize if I say anything incorrectly or am not clear on my explanations. I am creating a MEAN stack application, and all of the routing is working correctly when I put $locationProvider.html5Mode(true);
on my config and I also added
app.all('/*', function (req, res, next) {
res.sendFile('index.html', { root: __dirname + '/public' });
});
to my index.js on the server side, and <base href="/"></base>
on my index.html.
The problem is, on my html views, I have hrefs that connect to my server, and when I click on them, instead of calling the api, it will take me to localhost/api/..., which then redirects me back to the login page because it does not exist. (I am using passport local). When I remove $locationprovider and the rest of the above code, the hrefs work like they should.
Here is the example:
<a href="/connect/instagram"</a>
is listed on one of my views. This is supposed to take me to instagrams website so that I can authorize my account. When using $locationProvider, it takes me to localhost/connect/instagram, which doesn't exist, and therefore boots me out to the login page since that route doesn't exist.
I have tried removing the'/' in front of connect/instagram, and no luck. I am stuck at this point. Any help would be greatly appreciated!