I am working on a blog. I have an express server which has various APIs like /api/getpost , /api/newpost etc etc.
I have my react components and i am using react router 4 , my routes are /addpost /home etc. etc.
In my server.js i served my static files(bundel.js)
app.use(express.static(__dirname+'/dist'));
then
app.get('*', function(res,req){
res.sendFile(path.resolve(__dirname, 'index.html'));
});
localhost:3000/
loads homepage properly localhost:3000/home
also loads
localhost:3000/api/getpost
fails !
i couldn't find solution of this after several hours of searching
via Harkirat Singh
No comments:
Post a Comment