feat: allow any origin with CORS in favour of our manual validation

This commit is contained in:
Naomi Carrigan 2025-02-17 03:00:48 -08:00
parent 23e0bcc0b8
commit fc213289c2
Signed by: naomi
SSH Key Fingerprint: SHA256:rca1iUI2OhAM6n4FIUaFcZcicmri0jgocqKiTTAfrt8
3 changed files with 34 additions and 0 deletions

28
pnpm-lock.yaml generated
View File

@ -115,6 +115,9 @@ importers:
server:
dependencies:
'@fastify/cors':
specifier: 10.0.2
version: 10.0.2
'@nhcarrigan/logger':
specifier: 1.0.0
version: 1.0.0
@ -1065,6 +1068,9 @@ packages:
'@fastify/ajv-compiler@4.0.2':
resolution: {integrity: sha512-Rkiu/8wIjpsf46Rr+Fitd3HRP+VsxUFDDeag0hs9L0ksfnwx2g7SPQQTFL0E8Qv+rfXzQOxBJnjUB9ITUDjfWQ==}
'@fastify/cors@10.0.2':
resolution: {integrity: sha512-DGdxOG36sS/tZv1NFiCJGi7wGuXOSPL2CmNX5PbOVKx0C6LuIALRMrqLByHTCcX1Rbl8NJ9IWlJex32bzydvlw==}
'@fastify/error@4.0.0':
resolution: {integrity: sha512-OO/SA8As24JtT1usTUTKgGH7uLvhfwZPwlptRi2Dp5P4KKmJI3gvsZ8MIHnNwDs4sLf/aai5LzTyl66xr7qMxA==}
@ -3134,6 +3140,9 @@ packages:
fast-uri@3.0.6:
resolution: {integrity: sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==}
fastify-plugin@5.0.1:
resolution: {integrity: sha512-HCxs+YnRaWzCl+cWRYFnHmeRFyR5GVnJTAaCJQiYzQSDwK9MgJdyAsuL3nh0EWRCYMgQ5MeziymvmAhUHYHDUQ==}
fastify@5.2.1:
resolution: {integrity: sha512-rslrNBF67eg8/Gyn7P2URV8/6pz8kSAscFL4EThZJ8JBMaXacVdVE4hmUcnPNKERl5o/xTiBSLfdowBRhVF1WA==}
@ -4097,6 +4106,9 @@ packages:
engines: {node: '>=10'}
hasBin: true
mnemonist@0.39.8:
resolution: {integrity: sha512-vyWo2K3fjrUw8YeeZ1zF0fy6Mu59RHokURlld8ymdUPjMlD9EC9ov1/YPqTgqRvUN9nTr3Gqfz29LYAmu0PHPQ==}
mrmime@2.0.0:
resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==}
engines: {node: '>=10'}
@ -4259,6 +4271,9 @@ packages:
resolution: {integrity: sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==}
engines: {node: '>= 0.4'}
obliterator@2.0.5:
resolution: {integrity: sha512-42CPE9AhahZRsMNslczq0ctAEtqk8Eka26QofnqC346BZdHDySk3LWka23LI7ULIw11NmltpiLagIq8gBozxTw==}
obuf@1.1.2:
resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==}
@ -6855,6 +6870,11 @@ snapshots:
ajv-formats: 3.0.1(ajv@8.17.1)
fast-uri: 3.0.6
'@fastify/cors@10.0.2':
dependencies:
fastify-plugin: 5.0.1
mnemonist: 0.39.8
'@fastify/error@4.0.0': {}
'@fastify/fast-json-stringify-compiler@5.0.2':
@ -9149,6 +9169,8 @@ snapshots:
fast-uri@3.0.6: {}
fastify-plugin@5.0.1: {}
fastify@5.2.1:
dependencies:
'@fastify/ajv-compiler': 4.0.2
@ -10191,6 +10213,10 @@ snapshots:
mkdirp@3.0.1: {}
mnemonist@0.39.8:
dependencies:
obliterator: 2.0.5
mrmime@2.0.0: {}
ms@2.0.0: {}
@ -10374,6 +10400,8 @@ snapshots:
define-properties: 1.2.1
es-object-atoms: 1.1.1
obliterator@2.0.5: {}
obuf@1.1.2: {}
on-exit-leak-free@2.1.2: {}

View File

@ -24,6 +24,7 @@
"typescript": "5.7.3"
},
"dependencies": {
"@fastify/cors": "10.0.2",
"@nhcarrigan/logger": "1.0.0",
"@prisma/client": "6.3.1",
"fastify": "5.2.1",

View File

@ -4,6 +4,7 @@
* @author Naomi Carrigan
*/
import cors from "@fastify/cors";
import { PrismaClient } from "@prisma/client";
import fastify from "fastify";
import { authHook } from "./hooks/auth.js";
@ -25,6 +26,10 @@ try {
logger: false,
});
server.register(cors, {
origin: "*",
});
server.addHook("preHandler", authHook);
server.addHook("preHandler", corsHook);