allow cross origin node
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});var express = require('express')
var cors = require('cors')
var app = express()
app.use(cors())
app.get('/products/:id', function (req, res, next) {
res.json({msg: 'This is CORS-enabled for all origins!'})
})
app.listen(80, function () {
console.log('CORS-enabled web server listening on port 80')
})
Also in JavaScript:
- checkbox is checked jquery
- javascript data types
- how to get cwd nodejs
- kendo datasource get
- array sorting javascript mergesort
- wait for loop to finish javascript
- fetch is not defined amazon-cognito-identity-js
- cortar elemento y pegar en otro lugar jquery
- javascript close window
- import switch material ui
- display none in jquery
- Javascript get current year
- constructor react
- how run dockerfile
- package json proxy
- for in javascript
- jquery use variable in string "without" concatenate
- json search javascript
- curl post file json
- new features of angular 11
- react native button round
- p5 js lines
- convert shp to geojson python
- sleeping in js