whatsapp-api-nodejs
whatsapp-api-nodejs copied to clipboard
Is it possible to place a white list for the CROS to work?
I need to activate the CROS and if possible make a white list to be able to only have access from my server to another. The problem to solve would be this : Access to XMLHttpRequest at 'Server 1' from origin 'Server 2' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource .
It is my first time using all this environment, I await your answers
Express docs about cors middleware is very detailed https://expressjs.com/en/resources/middleware/cors.html
I came for the same request, do this in src/api/routes/index.js
:
const express = require('express')
const router = express.Router()
const instanceRoutes = require('./instance.route')
const messageRoutes = require('./message.route')
const miscRoutes = require('./misc.route')
const groupRoutes = require('./group.route')
const cors = require('cors');
router.get('/status', cors(), (req, res) => res.send('OK'))
router.use('/instance', cors(), instanceRoutes)
router.use('/message', cors(), messageRoutes)
router.use('/group', cors(), groupRoutes)
router.use('/misc', cors(), miscRoutes)
module.exports = router
I appreciate it if this could added as an optional procedure to this repo.
I came for the same request, do this in
src/api/routes/index.js
:const express = require('express') const router = express.Router() const instanceRoutes = require('./instance.route') const messageRoutes = require('./message.route') const miscRoutes = require('./misc.route') const groupRoutes = require('./group.route') const cors = require('cors'); router.get('/status', cors(), (req, res) => res.send('OK')) router.use('/instance', cors(), instanceRoutes) router.use('/message', cors(), messageRoutes) router.use('/group', cors(), groupRoutes) router.use('/misc', cors(), miscRoutes) module.exports = router
I appreciate it if this could be added as an optional procedure to this repo.
feel free to fork and make changes to your like.