CopyPastor

Detecting plagiarism made easy.

Score: 0.8036845811794802; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-10-17
by StepUp

Original Post

Original - Posted on 2013-08-19
by jvandemo



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Try to set explicitly your localhost and add desired types of methods:
// Add headers app.use(function (req, res, next) { // Website you wish to allow to connect res.setHeader('Access-Control-Allow-Origin', 'http://localhost:4200'); // desired types of methods res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); // Set to true if you need the website to include cookies in the requests sent // to the API (e.g. in case you use sessions) res.setHeader('Access-Control-Allow-Credentials', true); // Pass to next layer of middleware next(); });



Try adding the following middleware to your NodeJS/Express app (I have added some comments for your convenience):
// Add headers app.use(function (req, res, next) {
// Website you wish to allow to connect res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8888');
// Request methods you wish to allow res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
// Request headers you wish to allow res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
// Set to true if you need the website to include cookies in the requests sent // to the API (e.g. in case you use sessions) res.setHeader('Access-Control-Allow-Credentials', true);
// Pass to next layer of middleware next(); });
Hope that helps!

        
Present in both answers; Present only in the new answer; Present only in the old answer;