Hi all,
I am working on WebApis.
And Create a localApi for Post Method using Node Js.
When I hit the API using Angular (FrontEnd) the CORS Problem Occured. So I have added some code to Node js server. And Again I get the Same Error.
The Code Which I add in Serve Side:
app.use((function(req, res, next) {
res.header('Access-Control-Allow-Origin', 'http://localhost:4200');
res.header('Access-Control-Allow-Headers', "Origin, X-Requested-with, Content-Type, Accept, Authorization");
res.header('Access-Control-Allow-Methods', 'GET,HEAD,PUT,PATCH,POST,DELETE');
return res.status(200).json({});
next();
}));
Can any one say which point i am wrong ?
Top comments (1)
This isn’t stack overflow, your code isn’t formatted and you didn’t say what you tried at all, if you want help go to stack overflow and then come back and write a post here about what you learned is my recommendation 😉