add CORS support
This commit is contained in:
parent
b8cbcb74ef
commit
f24c0d2078
@ -267,7 +267,7 @@ export const resetPasswordMiddleware = (cntr: UserAccessor) =>
|
||||
}
|
||||
|
||||
export function createLoginRouter(userController: UserAccessor) {
|
||||
let router = new Router();
|
||||
const router = new Router();
|
||||
router.post('/login', createLoginMiddleware(userController));
|
||||
router.post('/logout', LogoutMiddleware);
|
||||
router.post('/refresh', createRefreshTokenMiddleware(userController));
|
||||
|
@ -64,6 +64,11 @@ class ServerApplication{
|
||||
let diff_router = createDiffRouter(this.diffManger);
|
||||
this.diffManger.register("comic",createComicWatcher());
|
||||
let router = new Router();
|
||||
router.use("/api/*", async (ctx,next)=>{
|
||||
//For CORS
|
||||
ctx.res.setHeader("access-control-allow-origin", "*");
|
||||
await next();
|
||||
});
|
||||
|
||||
router.use('/api/diff',diff_router.routes());
|
||||
router.use('/api/diff',diff_router.allowedMethods());
|
||||
@ -77,8 +82,8 @@ class ServerApplication{
|
||||
router.use('/api/doc',content_router.allowedMethods());
|
||||
|
||||
const tags_router = getTagRounter(this.tagController);
|
||||
router.use("/api/tags",tags_router.routes());
|
||||
router.use("/api/tags",tags_router.allowedMethods());
|
||||
router.use("/api/tags",tags_router.routes());
|
||||
|
||||
const login_router = createLoginRouter(this.userController);
|
||||
router.use('/user',login_router.routes());
|
||||
|
Loading…
Reference in New Issue
Block a user