Webpack Cross-domain problem options request returned 204 No Content?

  1. the technology stack is: there is no problem for webpack+vue+express, programs to run directly in the development environment. Then plan to separate the front and back end code, and configure the project to the production environment, so webpack is packaged directly into the dist directory, and then the index.html and static directories are placed in the static directory of nginx. Visit: http://localhost, you can see the login interface, but the execution of the login issued an options request and returned 204 No Content.
  2. the question is: why is there no post request for login, but only options request? How to deal with the cross-domain problem of front-end separation.
  3. existing processing: axios network library used in the front end, and axios.defaults.withCredentials = true; has been added; the back end uses the cors library, code: app.use (cors ({credentials: true}));
  4. The screenshot of
  5. question is as follows:
Mar.11,2021

204 is normal. Both 200and 204are returned by OPTIONS. As to why POST didn't send it, it's not clear. Let's see if it's wrong.

< H2 > add < / H2 >

how to deal with cross-domain issues in front and back end separate development:
use devServer.proxy in webpack configuration as a proxy, for example:

cors</a>

cors:

app.use(cors({
    origin: 'http://127.0.0.1', //webpackindex.htmlstaticnginxhtmlwebpackOriginhttp://127.0.0.1 
    allowedHeaders: 'Origin, x-requested-with, Content-Type, X-Token', //X-Token
    credentials: true //true cookie
}));
Menu