How Egg supports cross-domain requests for a single interface

how Egg supports cross-domain requests for a single interface, but not all interfaces of the service can be cross-domain requests ~

tried the following method:

async XXX () {
    const { ctx } = this;
    ctx.set("Access-Control-Allow-Origin", "*");
    ctx.set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, token");
    ctx.set("Access-Control-Allow-Credentials", true);
    ctx.set("Access-Control-Allow-Methods", "GET, POST, PUT, OPTIONS, DELETE");
    ...
}

but:

ask for advice ~

Dec.25,2021

https://github.com/eggjs/egg-.

https://eggjs.org/zh-cn/basic.


finally found that it was blocked by the user login layer ~

Menu