支持CROS
This commit is contained in:
@@ -33,6 +33,14 @@ export async function createServer(config: BridgeConfig): Promise<BridgeServer>
|
||||
});
|
||||
const coordinator = new RequestCoordinator();
|
||||
|
||||
app.addHook("onRequest", async (_request, reply) => {
|
||||
reply.raw.setHeader("Access-Control-Allow-Origin", "*");
|
||||
reply.raw.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
|
||||
reply.raw.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
|
||||
});
|
||||
|
||||
app.options("/*", async (_request, reply) => reply.status(204).send());
|
||||
|
||||
app.setErrorHandler((error, _request, reply) => {
|
||||
const fastifyError = error as Error & { code?: string; statusCode?: number };
|
||||
if (fastifyError.code === "FST_ERR_CTP_BODY_TOO_LARGE") {
|
||||
|
||||
Reference in New Issue
Block a user