mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-12-27 02:10:52 +08:00
Allow all CORS origin
This commit is contained in:
parent
0869d7b391
commit
b9b1cd8494
3 changed files with 12 additions and 1 deletions
10
api.js
10
api.js
|
@ -4,6 +4,7 @@ const config = require('wild-config');
|
|||
const restify = require('restify');
|
||||
const log = require('npmlog');
|
||||
const logger = require('restify-logger');
|
||||
const corsMiddleware = require('restify-cors-middleware2');
|
||||
const UserHandler = require('./lib/user-handler');
|
||||
const MailboxHandler = require('./lib/mailbox-handler');
|
||||
const MessageHandler = require('./lib/message-handler');
|
||||
|
@ -142,6 +143,15 @@ if (config.api.secure && certOptions.key) {
|
|||
|
||||
const server = restify.createServer(serverOptions);
|
||||
|
||||
const cors = corsMiddleware({
|
||||
origins: ['*'],
|
||||
allowHeaders: ['X-Access-Token'],
|
||||
allowCredentialsAllOrigins: true
|
||||
});
|
||||
|
||||
server.pre(cors.preflight);
|
||||
server.use(cors.actual);
|
||||
|
||||
// disable compression for EventSource response
|
||||
// this needs to be called before gzipResponse
|
||||
server.use((req, res, next) => {
|
||||
|
|
|
@ -8,7 +8,7 @@ secure=false
|
|||
|
||||
# If set requires all API calls to have accessToken query argument with that value
|
||||
# http://localhost:8080/users?accessToken=somesecretvalue
|
||||
#accessToken="somesecretvalue"
|
||||
accessToken="somesecretvalue"
|
||||
|
||||
[accessControl]
|
||||
# If true then require a valid access token to perform API calls
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
"pwnedpasswords": "1.0.5",
|
||||
"qrcode": "1.4.4",
|
||||
"restify": "8.5.1",
|
||||
"restify-cors-middleware2": "^2.1.2",
|
||||
"restify-logger": "2.0.1",
|
||||
"saslprep": "1.0.3",
|
||||
"seq-index": "1.1.0",
|
||||
|
|
Loading…
Reference in a new issue