aboutsummaryrefslogtreecommitdiff
path: root/pages/api/image.ts
blob: 122599ea914eb9c817b7212f0469a49c31d539e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { isBot } from 'next/dist/server/web/spec-extension/user-agent'
import type { NextRequest } from 'next/server'
import pngEndpoint from './png'
import svgEndpoint from './svg'

const imageEndpoint = async (req: NextRequest) => {
  if (isBot(req.headers.get('user-agent') ?? '')) {
    return pngEndpoint(req)
  } else {
    return svgEndpoint(req)
  }
}

export const config = {
  runtime: 'experimental-edge'
}

export default imageEndpoint