Socialify

Folder ..

Viewing image.ts
18 lines (15 loc) • 448.0 B

 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