I am facing following error : Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.1.217:3001/api/login?id=a&ps=x&ip=20.85.153.255&loc=Washington%2022747%20Virginia%20United%20States. (Reason: CORS request did not succeed). Status code: (null).
My setup is Public IP --------> 192.168.1.217:80 ( front end ) -------------> 192.168.1.217:3001 ( backend ) 1) with this setup , project not able to communicate between port 80 ( front end ) to 3001 ( backend ) as orinial request is coming from external IP . 2) and error message The Same Origin Policy disallows reading the remote resource 3) I use nodejs express const cors = require('cors'); const app = express(); app.use(cors({ origin: '*' })); app.use("/", express.static(path.join(__dirname, "angular"))); app.use((req, res, next) => { // res.setHeader("Access-Control-Allow-Origin", "*"); // res.setHeader("Access-Control-Allow-Credentials", "true"); // res.setHeader("Access-Control-Allow-Headers", "Content-Type, accept , Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control"); // res.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, DELETE, OPTIONS"); res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Credentials", "true"); res.header("Access-Control-Allow-Headers", "Content-Type, accept , Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control"); res.header("Access-Control-Allow-Methods", "GET, POST, PATCH, DELETE, OPTIONS"); next(); }); Not sure what mistake I am doing here -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/6612d81c-37c6-4cd7-beba-354fadcdc54bn%40googlegroups.com.