Skip to content

Commit

Permalink
enable CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
devksingh4 committed Aug 6, 2024
1 parent 02e843a commit 7130fe9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@aws-sdk/util-dynamodb": "^3.624.0",
"@fastify/auth": "^4.6.1",
"@fastify/aws-lambda": "^4.1.0",
"@fastify/cors": "^9.0.1",
"fastify": "^4.28.1",
"fastify-plugin": "^4.5.1",
"jsonwebtoken": "^9.0.2",
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import errorHandlerPlugin from "./plugins/errorHandler.js";
import { RunEnvironment, runEnvironments } from "./roles.js";
import { InternalServerError } from "./errors/index.js";
import eventsPlugin from "./routes/events.js";
import cors from '@fastify/cors'

Check failure on line 11 in src/index.ts

View workflow job for this annotation

GitHub Actions / Run Unit Tests

Replace `'@fastify/cors'` with `"@fastify/cors";`

const now = () => Date.now();

Expand Down Expand Up @@ -62,6 +63,10 @@ async function init() {
},
{ prefix: "/api/v1" },
);
await app.register(cors, {

Check failure on line 66 in src/index.ts

View workflow job for this annotation

GitHub Actions / Run Unit Tests

Delete `·`
origin: (process.env.ValidCorsOrigins || "*").split(',')

Check failure on line 67 in src/index.ts

View workflow job for this annotation

GitHub Actions / Run Unit Tests

Replace `',')` with `","),`
})

Check failure on line 68 in src/index.ts

View workflow job for this annotation

GitHub Actions / Run Unit Tests

Insert `;`

Check failure on line 69 in src/index.ts

View workflow job for this annotation

GitHub Actions / Run Unit Tests

Delete `··`
return app;
}

Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,14 @@
resolved "https://registry.yarnpkg.com/@fastify/aws-lambda/-/aws-lambda-4.1.0.tgz#67dc617bbd596e078bee6e83a4ec9d31dee7686b"
integrity sha512-293HSdtr4muZZi4UxjrDgddxlLRDbNxT5x/eOX78obMA1Du3tfpuP7WuyfnA4GXaeckj/soJ2jiuD2sM4VIW9Q==

"@fastify/cors@^9.0.1":
version "9.0.1"
resolved "https://registry.yarnpkg.com/@fastify/cors/-/cors-9.0.1.tgz#9ddb61b4a61e02749c5c54ca29f1c646794145be"
integrity sha512-YY9Ho3ovI+QHIL2hW+9X4XqQjXLjJqsU+sMV/xFsxZkE8p3GNnYVFpoOxF7SsP5ZL76gwvbo3V9L+FIekBGU4Q==
dependencies:
fastify-plugin "^4.0.0"
mnemonist "0.39.6"

"@fastify/error@^3.3.0", "@fastify/error@^3.4.0":
version "3.4.1"
resolved "https://registry.yarnpkg.com/@fastify/error/-/error-3.4.1.tgz#b14bb4cac3dd4ec614becbc643d1511331a6425c"
Expand Down Expand Up @@ -3462,6 +3470,13 @@ [email protected]:
dependencies:
obliterator "^1.6.1"

[email protected]:
version "0.39.6"
resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.39.6.tgz#0b3c9b7381d9edf6ce1957e74b25a8ad25732f57"
integrity sha512-A/0v5Z59y63US00cRSLiloEIw3t5G+MiKz4BhX21FI+YBJXBOGW0ohFxTxO08dsOYlzxo87T7vGfZKYp2bcAWA==
dependencies:
obliterator "^2.0.1"

[email protected]:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
Expand Down Expand Up @@ -3547,6 +3562,11 @@ obliterator@^1.6.1:
resolved "https://registry.yarnpkg.com/obliterator/-/obliterator-1.6.1.tgz#dea03e8ab821f6c4d96a299e17aef6a3af994ef3"
integrity sha512-9WXswnqINnnhOG/5SLimUlzuU1hFJUc8zkwyD59Sd+dPOMf05PmnYG/d6Q7HZ+KmgkZJa1PxRso6QdM3sTNHig==

obliterator@^2.0.1:
version "2.0.4"
resolved "https://registry.yarnpkg.com/obliterator/-/obliterator-2.0.4.tgz#fa650e019b2d075d745e44f1effeb13a2adbe816"
integrity sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ==

on-exit-leak-free@^2.1.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz#fed195c9ebddb7d9e4c3842f93f281ac8dadd3b8"
Expand Down

0 comments on commit 7130fe9

Please sign in to comment.