Skip to content

Commit

Permalink
trifid: use @fastify/cors for CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovicm67 committed Oct 10, 2023
1 parent 04513e9 commit c5b2199
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-adults-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid": minor
---

Use @fastify/cors for CORS
28 changes: 28 additions & 0 deletions package-lock.json

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

7 changes: 7 additions & 0 deletions packages/trifid/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @ts-check
import Fastify from 'fastify'
import cors from '@fastify/cors'

import healthMiddleware from './middlewares/health.js'

const server = Fastify({
Expand All @@ -8,6 +10,11 @@ const server = Fastify({
},
})

await server.register(cors, {
origin: '*',
credentials: true,
})

// Health check
server.get('/healthz', healthMiddleware)

Expand Down
1 change: 1 addition & 0 deletions packages/trifid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"trifid": "./server.js"
},
"dependencies": {
"@fastify/cors": "^8.4.0",
"fastify": "^4.23.2"
}
}

0 comments on commit c5b2199

Please sign in to comment.