Created
October 31, 2018 13:31
-
-
Save rajaramtt/195628feb92e4609581fc8cc6ca782b8 to your computer and use it in GitHub Desktop.
CORS headers in node, php
This file contains 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
app.use(function (req, res, next) { | |
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:4200'); | |
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); | |
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); | |
res.setHeader('Access-Control-Allow-Credentials', true); | |
next(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Max-Age: 1000");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Cache-Control, Pragma, Authorization, Accept, Accept-Encoding");
header("Access-Control-Allow-Methods: PUT, POST, GET, OPTIONS, DELETE");