add simple refer check
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m0s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m0s
This commit is contained in:
17
src/app.ts
17
src/app.ts
@@ -6,6 +6,23 @@ const app = express();
|
||||
// 中间件
|
||||
app.use(express.json());
|
||||
|
||||
app.use((req, res, next) => {
|
||||
const origin = req.headers.origin || '';
|
||||
const referer = req.headers.referer || '';
|
||||
|
||||
// 判断是否来自 kintone 页面
|
||||
const isFromKintone =
|
||||
origin.includes('.kintone.com') ||
|
||||
origin.includes('.cybozu.com') ||
|
||||
referer.includes('.kintone.com') ||
|
||||
referer.includes('.cybozu.com');
|
||||
|
||||
if (!isFromKintone) {
|
||||
return res.status(403).json({ error: 'Forbidden: only allow kintone.proxy access' });
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
// 设置路由
|
||||
setupLicenseRoutes(app);
|
||||
|
||||
|
||||
@@ -23,5 +23,8 @@ async function handleLicenseCheck(req: Request, res: Response): Promise<void> {
|
||||
}
|
||||
|
||||
function handleHealthCheck(req: Request, res: Response): void {
|
||||
res.json({ status: 'OK' });
|
||||
res.json({
|
||||
status: 'OK',
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user