POST Request to expressjs not working despite using CORS
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.