diff --git a/.env.example b/.env.example index aa808a3..e869ae8 100644 --- a/.env.example +++ b/.env.example @@ -22,4 +22,6 @@ SFTP_HOST=host.com SFTP_DESTINATION_PATH_ROOT="/absolute/path/to/destination/root/folder" SFTP_BASE_URL=https://base-url.com -PAYLOAD_PUBLIC_FRONTEND_BASE_URL=https://domain.com \ No newline at end of file +PAYLOAD_PUBLIC_FRONTEND_BASE_URL=https://domain.com + +RATING_LIMIT_SKIP_TOKEN=ratelimitskiptoken5e6ea45ef4e66eaa151612bdcb599df \ No newline at end of file diff --git a/src/payload.config.ts b/src/payload.config.ts index 53c6526..2b2a664 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -4,7 +4,6 @@ import { cloudStorage } from "@payloadcms/plugin-cloud-storage"; import path from "path"; import { buildConfig } from "payload/config"; import { sftpAdapter } from "payloadcms-sftp-storage"; -import { mustBeAdmin } from "./accesses/collections/mustBeAdmin"; import { Audios } from "./collections/Audios/Audios"; import { ChronologyEvents } from "./collections/ChronologyEvents/ChronologyEvents"; import { Collectibles } from "./collections/Collectibles/Collectibles"; @@ -91,7 +90,7 @@ export default buildConfig({ rateLimit: { window: 900_000, // 15 minutes max: 500, - skip: (req) => !!mustBeAdmin({ req }), + skip: (request) => request.headers["x-rate-limit-skip"] === process.env.RATING_LIMIT_SKIP_TOKEN, }, plugins: [ cloudStorage({ diff --git a/src/sdk.ts b/src/sdk.ts index fcb8839..c73b026 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -74,7 +74,11 @@ const getToken = async (): Promise => { const injectAuth = async (init?: RequestInit): Promise => ({ ...init, - headers: { ...init?.headers, Authorization: `JWT ${await getToken()}` }, + headers: { + ...init?.headers, + Authorization: `JWT ${await getToken()}`, + "x-rate-limit-skip": process.env.PAYLOAD_RATING_LIMIT_SKIP_TOKEN ?? "", + }, }); const logResponse = (res: Response) => console.log(res.status, res.statusText, res.url);