forked from solana-foundation/templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddleware.ts
More file actions
23 lines (21 loc) · 737 Bytes
/
middleware.ts
File metadata and controls
23 lines (21 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
if (request.method === 'OPTIONS') {
const response = new NextResponse(null, { status: 204 })
response.headers.set('Access-Control-Allow-Origin', '*')
response.headers.set('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS')
response.headers.set('Access-Control-Allow-Headers', '*')
return response
}
return NextResponse.next({
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,OPTIONS',
'Access-Control-Allow-Headers': '*',
},
})
}
export const config = {
matcher: '/:path*',
}