How to solve the online Cross-Domain problem by axios

because the sever side belongs to someone else, you can only handle cross-domain requests at the front end

axios how to deal with cross-domain problems. My configuration in proxyTable only works locally

Cross-domain problems occur again in the online environment


CORS or nginx proxy or interface development that cannot be solved by online cross-domain front end


Let me give you a link. This question has been fiercely answered
https://codeshelper.com/q/10.


quickly and directly using nginx proxy


in this case, it seems that we can only reverse proxy


for the time being, use JsonBird to solve it. However, there is a certain delay. Currently, we have not found a better way


CORS (Cross-Origin Resource Sharing, cross-source resource sharing) HTTP access control technology, but there is a compatibility problem.


ask the bosses to spray lightly, our front-end and front-end separate projects, running in an Express service, the code is as follows, the middleware used by the agent, http-proxy-middleware.
`var express = require ('express');
var proxyMiddleware = require (' http-proxy-middleware');
var apiHost =' http://172.16.0.249:8181';
var proxyTable = {
'/ v1mm: {

target: apiHost,
changeOrigin: true,

},
'/ preview': {

target: apiHost,
changeOrigin: true,

},
'/ download': {

target: apiHost,
changeOrigin: true,

}
};

var app = express ();
var port = 4000;
Object.keys (proxyTable) .forEach (function (context) {
var options = proxyTable [context];
if (typeof options = 'string') {

options = { target: options }

}
app.use (proxyMiddleware (options.filter | | context, options))
});
app.use (require ('connect-history-api-fallback') ());
app.use (express.static ('. / dist'));
var uri =' http://localhost:' + port;

)

var _ resolve;
var readyPromise = new Promise (function (resolve) {
_ resolve = resolve;
});

console.log ('> Starting prod server.' + uri);

)

var server = app.listen (port);

module.exports = {

ready: readyPromise,
close: function() {
  server.close()
}

}; `

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32b03-341e3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32b03-341e3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?