Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
20 lines
617 B
TypeScript
20 lines
617 B
TypeScript
import { forbiddenResponse, sleep } from '~/utils/response';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
event.node.res.setHeader(
|
|
'Access-Control-Allow-Origin',
|
|
event.headers.get('Origin') ?? '*',
|
|
);
|
|
if (event.method === 'OPTIONS') {
|
|
event.node.res.statusCode = 204;
|
|
event.node.res.statusMessage = 'No Content.';
|
|
return 'OK';
|
|
} else if (
|
|
['DELETE', 'PATCH', 'POST', 'PUT'].includes(event.method) &&
|
|
event.path.startsWith('/api/system/')
|
|
) {
|
|
await sleep(Math.floor(Math.random() * 2000));
|
|
return forbiddenResponse(event, '演示环境,禁止修改');
|
|
}
|
|
});
|