[API] Add CORS
This commit is contained in:
parent
1468adbc45
commit
767213b7be
3 changed files with 27 additions and 5 deletions
13
api/app.js
13
api/app.js
|
@ -1,10 +1,17 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path');
|
||||||
const AutoLoad = require('fastify-autoload')
|
const AutoLoad = require('fastify-autoload');
|
||||||
|
const CORS = require('fastify-cors');
|
||||||
|
|
||||||
module.exports = function (fastify, opts, next) {
|
module.exports = function (fastify, opts, next) {
|
||||||
// Place here your custom code!
|
fastify.register(CORS, {
|
||||||
|
origin: 'http://localhost:3000',
|
||||||
|
preflight: true,
|
||||||
|
preflightContinue: true,
|
||||||
|
credentials: true,
|
||||||
|
methods: ['GET', 'PUT', 'PATCH', 'POST', 'DELETE'],
|
||||||
|
})
|
||||||
|
|
||||||
// Do not touch the following lines
|
// Do not touch the following lines
|
||||||
|
|
||||||
|
|
14
api/package-lock.json
generated
14
api/package-lock.json
generated
|
@ -1304,6 +1304,15 @@
|
||||||
"yargs-parser": "^13.0.0"
|
"yargs-parser": "^13.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"fastify-cors": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fastify-cors/-/fastify-cors-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-bLV7OIZ7ojvLaf0jOEsqAO4ShrBSc6412R6SVDIrFK6vIUAezTAVgk9MqcklZnc3ch/N/IC9kGPu5AfhqAIHkg==",
|
||||||
|
"requires": {
|
||||||
|
"fastify-plugin": "^1.6.0",
|
||||||
|
"vary": "^1.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"fastify-plugin": {
|
"fastify-plugin": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-1.6.0.tgz",
|
||||||
|
@ -4749,6 +4758,11 @@
|
||||||
"spdx-expression-parse": "^3.0.0"
|
"spdx-expression-parse": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"vary": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||||
|
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
|
||||||
|
},
|
||||||
"verror": {
|
"verror": {
|
||||||
"version": "1.10.0",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
|
||||||
|
|
|
@ -16,9 +16,10 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fastify": "^2.0.0",
|
"fastify": "^2.0.0",
|
||||||
"fastify-plugin": "^1.5.0",
|
|
||||||
"fastify-autoload": "^1.0.0",
|
"fastify-autoload": "^1.0.0",
|
||||||
"fastify-cli": "^1.3.0"
|
"fastify-cli": "^1.3.0",
|
||||||
|
"fastify-cors": "^3.0.0",
|
||||||
|
"fastify-plugin": "^1.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tap": "^12.5.3"
|
"tap": "^12.5.3"
|
||||||
|
|
Loading…
Add table
Reference in a new issue