I have a followed your approach but i am facing a issue.
I have one home page route at express from which i want to pass through a middle-ware function isResturantOpen when ever the user visits the react app.
app.get('/',passportConfig.isResturantOpen, (req,res) =>{ console.log('reached') res.sendFile(path.join(__dirname+'/client/build/index.html')); });
but when i ever i tries to visit my website home of react.js at this url localhost:5000/ then my above route does not work
but all the routes are being going to this main route.
app.get('*', (req,res) =>{ console.log(req) // console.log(res) res.sendFile(path.join(__dirname+'/client/build/index.html')); });
so now if i want to apply some different express.js middle ware functions on each different routes then how can i do this..?
Can you please help me on this.?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have a followed your approach but i am facing a issue.
I have one home page route at express from which i want to pass through a middle-ware function isResturantOpen when ever the user visits the react app.
app.get('/',passportConfig.isResturantOpen, (req,res) =>{
console.log('reached')
res.sendFile(path.join(__dirname+'/client/build/index.html'));
});
but when i ever i tries to visit my website home of react.js at this url
localhost:5000/ then my above route does not work
but all the routes are being going to this main route.
app.get('*', (req,res) =>{
console.log(req)
// console.log(res)
res.sendFile(path.join(__dirname+'/client/build/index.html'));
});
so now if i want to apply some different express.js middle ware functions on each different routes then how can i do this..?
Can you please help me on this.?