From 6849308fb56ec7774fff15136fa07ddef3202397 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Sat, 27 Sep 2025 14:48:46 -0700 Subject: [PATCH] feat: allow any cors --- package.json | 1 + pnpm-lock.yaml | 16 ++++++++++++++++ src/index.ts | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/package.json b/package.json index d5b6d46..bbfa2b5 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "license": "ISC", "packageManager": "pnpm@10.17.0", "dependencies": { + "@fastify/cors": "11.1.0", "@nhcarrigan/logger": "1.0.0", "fastify": "5.6.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b3324e..b71a87e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@fastify/cors': + specifier: 11.1.0 + version: 11.1.0 '@nhcarrigan/logger': specifier: 1.0.0 version: 1.0.0 @@ -503,6 +506,9 @@ packages: '@fastify/ajv-compiler@4.0.2': resolution: {integrity: sha512-Rkiu/8wIjpsf46Rr+Fitd3HRP+VsxUFDDeag0hs9L0ksfnwx2g7SPQQTFL0E8Qv+rfXzQOxBJnjUB9ITUDjfWQ==} + '@fastify/cors@11.1.0': + resolution: {integrity: sha512-sUw8ed8wP2SouWZTIbA7V2OQtMNpLj2W6qJOYhNdcmINTu6gsxVYXjQiM9mdi8UUDlcoDDJ/W2syPo1WB2QjYA==} + '@fastify/error@4.2.0': resolution: {integrity: sha512-RSo3sVDXfHskiBZKBPRgnQTtIqpi/7zhJOEmAxCiBcM7d0uwdGdxLlsCaLzGs8v8NnxIRlfG0N51p5yFaOentQ==} @@ -1429,6 +1435,9 @@ packages: fast-uri@3.1.0: resolution: {integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==} + fastify-plugin@5.0.1: + resolution: {integrity: sha512-HCxs+YnRaWzCl+cWRYFnHmeRFyR5GVnJTAaCJQiYzQSDwK9MgJdyAsuL3nh0EWRCYMgQ5MeziymvmAhUHYHDUQ==} + fastify@5.6.1: resolution: {integrity: sha512-WjjlOciBF0K8pDUPZoGPhqhKrQJ02I8DKaDIfO51EL0kbSMwQFl85cRwhOvmSDWoukNOdTo27gLN549pLCcH7Q==} @@ -2978,6 +2987,11 @@ snapshots: ajv-formats: 3.0.1(ajv@8.17.1) fast-uri: 3.1.0 + '@fastify/cors@11.1.0': + dependencies: + fastify-plugin: 5.0.1 + toad-cache: 3.7.0 + '@fastify/error@4.2.0': {} '@fastify/fast-json-stringify-compiler@5.0.3': @@ -4181,6 +4195,8 @@ snapshots: fast-uri@3.1.0: {} + fastify-plugin@5.0.1: {} + fastify@5.6.1: dependencies: '@fastify/ajv-compiler': 4.0.2 diff --git a/src/index.ts b/src/index.ts index 784ec30..a37c883 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ * @author Naomi Carrigan */ +import cors from "@fastify/cors"; import fastify from "fastify"; import { buildRoutes } from "./modules/buildRoutes.js"; import { logger } from "./utils/logger.js"; @@ -12,6 +13,10 @@ const server = fastify({ logger: false, }); +server.register(cors, { + origin: true, +}); + await buildRoutes(server); server.get("/", async(_request, response) => {