Next.js Discord

Discord Forum

collect ddosers' ips

Unanswered
piscopancer posted this in #help-forum
Open in Discord
I'd like to use middleware to write ips that request my site. I will let ddos run for 1 hour and all the ips will be written to the text file, Unfortunately, fs and fs/promises cannot be used on the edge runtime. What can I do?

import fs from 'fs/promises'
import type { NextRequest } from 'next/server'

export async function middleware(request: NextRequest) {
  const ip = request.headers.get('X-Forwarded-For')
  if (ip) {
    // await fs.writeFile('./ips.txt', ip)
  }
}

1 Reply

American Chinchilla
Use axiom