Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. Console error in Node JS

XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. Console error in Node JS

Guest Post :
Console error in Node JS
As nodejs Server is running on 3000 port, how to send data to angular app which is running in 9000 port. Server and client are both in my local machine.


XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. 

Solution :

Add Cors to express server because your trying to access the server on a different port than the client it will through a cors error. Install cors and then app.use(cors())

npm install cors -- save
Add this to server.js
const cors = require ('cors');
app.use(cors);

Users Please post your solution.


This post first appeared on Asp.netSourceCodes, please read the originial post: here

Share the post

XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. Console error in Node JS

×

Subscribe to Asp.netsourcecodes

Get updates delivered right to your inbox!

Thank you for your subscription

×