Koa interface cross-domain error report

several interfaces are written with koa+mongodb. Cross-domain errors are always reported when requesting with ajax, even if cors is used in koa. Google has done a lot of things but still hasn"t solved the problem

.
const cors = require("koa2-cors");
var MongoClient = require("mongodb").MongoClient;
var DB_URL = "mongodb://localhost:27017/test";
// app.use(cors());
app.use(cors({
    origin: function (ctx) {
            return "*"; // 
    },
    exposeHeaders: ["WWW-Authenticate", "Server-Authorization"],
    maxAge: 5,
    credentials: true,
    allowMethods: ["GET", "POST", "DELETE"],
    allowHeaders: ["Content-Type", "Authorization", "Accept"],
}))
//
app.use(router["routes"]());
router.get("/",findFn)
router.get("/add",insertFn)
app.listen(3000);

Let the interface that requests localhost:3000 in my localhost:1234/index.html page report the error (Failed to load localhost:3000: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. shown above)

I hope you can give me some advice. Thank you

Feb.28,2021

your error is not a cross-domain error. It seems to be a request that you directly hit the developer locally. Start a service and try


if it is not the back-end code from response , post the front-end code. The error message says only supported for protocol schemes:http, data, chrome, chrome-extension, https , and it is suspected that you scheme has made a mistake.


it's embarrassing that the address of the resolved request forgot to add http://.

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