Skip to content

Commit

Permalink
chore: add cors to fastify
Browse files Browse the repository at this point in the history
  • Loading branch information
luandro committed Feb 12, 2025
1 parent d2e429b commit a3ddaa2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
},
"dependencies": {
"@comapeo/core": "^2.3.1",
"@fastify/cors": "^8.5.0",
"@fastify/sensible": "^5.6.0",
"@fastify/swagger": "^8.15.0",
"@fastify/swagger-ui": "^2.1.0",
Expand Down
5 changes: 5 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cors from '@fastify/cors'
import { Type } from '@sinclair/typebox'
import envSchema from 'env-schema'
import createFastify from 'fastify'
Expand Down Expand Up @@ -81,6 +82,10 @@ const fastify = createFastify({
trustProxy: true,
})

await fastify.register(cors, {
// put your options here
})

// Register Swagger
// @ts-ignore
await fastify.register(import('@fastify/swagger'), {
Expand Down

0 comments on commit a3ddaa2

Please sign in to comment.