Created
November 18, 2019 14:46
-
-
Save haseebpvt/02b94ad01ea9606f9d61070170a67198 to your computer and use it in GitHub Desktop.
Code for cors error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //var express = require('express'); | |
| //var app = express(); | |
| app.use((req, res, next) => { | |
| res.header('Access-Control-Allow-Origin', '*'); | |
| res.header('Access-Control-Allow-Headers', "Origin, X-Requested-With, Content-Type, Accept, Authorization"); | |
| if (req.method === 'OPTIONS') { | |
| res.header('Access-Control-Allow-Method', 'PUT, POST, PATCH, DELETE, GET'); | |
| return res.status(200).json({}); | |
| } | |
| next(); | |
| }); | |
| //app.get('/old', function(req, res) { | |
| //console.log('Get called: ' + value.msg); | |
| //res.send(value); | |
| //}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment