CORS cross-domain request
- You can configure it globally in
ndsk.config.json
or in a single route, default iscros:false
module.exports = (isPro)=>{
return {
server:{
routes:{
cors:{
origin:['*'], //
headers:['Accept', 'Authorization', 'Content-Type', 'If-None-Match']
// ...
}
}
}
}
}
export const options = {
cors:{
origin:['*'],
headers:['Accept', 'Authorization', 'Content-Type', 'If-None-Match'],
additionalHeaders:['X-Requested-With-']
},
}
export default (request,h)=>{
return 'welcome'
}
origin
The server to allow requests to.ip
A string or array. If set to'*'
or['*']
, any request origin is allowed.headers
An array of strings of allowed headers (‘Access-Control-Allow-Headers’). Defaults to:['Accept', 'Authorization', 'Content-Type', 'If-None-Match']
- You can view the detailed configuration document here