POST Request to expressjs not working despite using CORS POST Request to expressjs not working despite using CORS vue.js vue.js

POST Request to expressjs not working despite using CORS


Try moving the app.use(cors())up before you assign the routes


The pre-flight part is referring to xhr making a OPTIONS request to /api/v1/addComment before the actual POST. You'll need to configure cors to handle that:

// preflight for aspecific routerouter.options('/api/v1/addComment/', cors())// or preflight for all routesrouter.options('*', cors())

Note: you'll want to make these calls before defining the rest of the routes. See the docs on npmjs.