Why does vue return cross-domain access to backend interfaces?

create two services with a virtual machine:
1 is the vue project created by vue-cli3, port is 8080 configured vue.config.js cross-domain part:

clipboard.png

:

clipboard.png

2 is the koa backend usage port http://127.0.0.1:3030

but somehow clicking the button on the vue page to request http://127.0.0.1:3030 shows a cross-domain error

ps: I use the interface to convert access under windows!

Jun.15,2022

two service ports are different, so they must be two different domains. You can use koa2-cors to handle cross-domain


you have written the wrong request. The proxy is represented by devserver for you. You do not need to write the address of the back-end server directly during the front-end request.
configure

proxy: {
  "/api": "http://localhost:3030"
}

when you request, you still use 8080 to request. For example, if you request'/ api/user', you will proxy' http://127.0.0.1:3030/api/user'

.
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-1bc9c6a-2feeb.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-1bc9c6a-2feeb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?