Skip to content

Commit 06b57ac

Browse files
committed
fix(templates): handle cors form studio
1 parent 4e1b2e6 commit 06b57ac

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/server/api/templates.json.get.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1+
import { handleCors } from 'h3'
2+
13
export default defineEventHandler(async (event) => {
4+
const didHandleCors = handleCors(event, {
5+
origin: ['https://nuxt.studio', 'https://dev.nuxt.studio'],
6+
preflight: {
7+
statusCode: 204,
8+
},
9+
methods: '*',
10+
})
11+
12+
if (didHandleCors) {
13+
return
14+
}
15+
216
const templates = await queryCollection(event, 'templates').all()
317

418
if (!templates) {

0 commit comments

Comments
 (0)