After the create-react-app project is packaged, the cross-domain json cannot be recognized by the ssm backend.

my project create-react-app serves as the foreground, ssm serves as the background, and the foreground json is passed to the background through cross-domain means.
the setting of the proxy agent in package.json

"proxy": {
"/api/php": {
  "target": "http://localhost:8080/shbaokangsoft-1.0.0-SNAPSHOT",
  "ws": true,
  "changeOrigin": true,
  "pathRewrite": {
    "^/api/php": ""
  }
}

},
the foreground is not packed, and there is no problem when accessing the background.
the foreground is packaged and deployed using the serve-s command. As a result, the cross-domain proxy settings no longer seem to work, Json is no longer recognized, and whether the
is not comprehensive enough (whether the packages are all packaged with npm run build), or the cross-domain settings after packaging are not set as above.


proxy is only valid in development mode, and the production environment does not take effect after build


the path "/ api/php" cannot be replaced with "http://localhost:8080/shbaokangsoft-1.0.0-SNAPSHOT"" after packaging, but the agent still works. Just write the path prefix http://localhost:8080/shbaokangsoft-1.0.0-SNAPSHOT directly in axios.post ().

Menu