Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should fix rate limit issues #99

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
21 changes: 18 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"dotenv": "^8.2.0",
"escape-html": "^1.0.3",
"express": "^4.21.0",
"express-rate-limit": "^7.4.0",
"jssha": "^3.3.1",
"md5": "^2.3.0",
"moment-timezone": "^0.5.45",
Expand Down
2 changes: 2 additions & 0 deletions src/payload/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ export default buildConfig({
formBuilder({}),
],
rateLimit: {
window: 60000,
max: 600,
trustProxy: true,
},
})
11 changes: 11 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,22 @@ dotenv.config({
})

import express from 'express'
// import { rateLimit } from 'express-rate-limit'
import payload from 'payload'

import { seed } from './payload/seed'

const app = express()

// const limiter = rateLimit({
// windowMs: 15 * 60 * 1000, // 15 minutes
// max: 200, // Limit each IP to 100 requests per windowMs
// message: 'Too many requests from this IP, please try again later.',
// headers: true, // Include rate limit headers in the response
// })

// app.use(limiter)

const PORT = process.env.PORT || 3000

const start = async (): Promise<void> => {
Expand Down
Loading