From 028d7d80ec956c50dbd977c974fde6d83e2732be Mon Sep 17 00:00:00 2001 From: Lucemans Date: Mon, 30 May 2022 01:37:02 +0200 Subject: [PATCH] Introduce CORS --- package.json | 1 + src/index.ts | 5 +++++ yarn.lock | 10 +++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 42acfc38..bf1b5cfd 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "author": "lucemans ", "license": "GPL-3.0", "dependencies": { + "@fastify/cors": "^7.0.0", "@lvksh/logger": "^1.6.0", "@sentry/node": "^6.17.3", "@sentry/tracing": "^6.17.3", diff --git a/src/index.ts b/src/index.ts index e7284aef..dffa6c2f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ +import Cors from '@fastify/cors'; import chalk from 'chalk'; import { config } from 'dotenv'; import { fastify } from 'fastify'; @@ -61,6 +62,10 @@ export const StorageBackend: GenericStorage = new SignalStorage(); log.lifecycle('Starting Express'); + server.register(Cors, { + origin: true, + allowedHeaders: ['GET', 'PUT', 'POST'], + }); server.register(CreateRoute, { prefix: '/deployments' }); server.register(ApiRoute, { prefix: '/api' }); server.register(GenericRoute); diff --git a/yarn.lock b/yarn.lock index 25af2e13..18aef291 100644 --- a/yarn.lock +++ b/yarn.lock @@ -417,6 +417,14 @@ dependencies: text-decoding "^1.0.0" +"@fastify/cors@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@fastify/cors/-/cors-7.0.0.tgz#c67c5a5909498b696bb19578e903f36037ac6f32" + integrity sha512-nlo6ScwagBNJacAZD3KX90xjWLIoV0vN9QqoX1wUE9ZeZMdvkVkMZCGlxEtr00NshV0X5wDge4w5rwox7rRzSg== + dependencies: + fastify-plugin "^3.0.0" + vary "^1.1.2" + "@humanwhocodes/config-array@^0.9.2": version "0.9.2" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.9.2.tgz#68be55c737023009dfc5fe245d51181bb6476914" @@ -4705,7 +4713,7 @@ varint@^6.0.0: resolved "https://registry.yarnpkg.com/varint/-/varint-6.0.0.tgz#9881eb0ce8feaea6512439d19ddf84bf551661d0" integrity sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg== -vary@~1.1.2: +vary@^1.1.2, vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=