Skip to content

Commit

Permalink
Merge pull request #49 from Superlight-Labs/42-docker-azure-deploy
Browse files Browse the repository at this point in the history
fix(api): allow cors
  • Loading branch information
lauhon authored Jun 16, 2023
2 parents 1e30605 + c16aaac commit 72aa292
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
5 changes: 3 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"license": "ISC",
"dependencies": {
"@fastify/cookie": "^8.3.0",
"@fastify/cors": "^8.3.0",
"@fastify/type-provider-typebox": "^3.1.0",
"@fastify/under-pressure": "^8.2.0",
"@fastify/websocket": "^7.2.0",
Expand All @@ -39,8 +40,8 @@
"openpgp": "^5.5.0",
"ref-napi": "^3.0.3",
"rxjs": "^7.8.0",
"tsconfig-paths": "^4.1.2",
"ts-node": "^10.9.1"
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.2"
},
"devDependencies": {
"@superlight-labs/eslint-config": "*",
Expand Down
11 changes: 10 additions & 1 deletion apps/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import config from '@lib/config';
import logger from '@superlight-labs/logger';
import { registerRoutes } from './routes/register-routes';

import cors from '@fastify/cors';
import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox';
import { PrismaClient } from '@superlight-labs/database';
import fastify from 'fastify';
Expand All @@ -29,6 +30,10 @@ export const createServer = async (client: PrismaClient) => {
server.register(fastifyCookie, {
secret: config.cookieSecret,
});
server.register(cors, {
origin: '*',
methods: ['GET', 'PUT', 'POST'],
});

server.register(underPressure, {
maxHeapUsedBytes: 500 * 1000000,
Expand All @@ -47,7 +52,11 @@ export const createServer = async (client: PrismaClient) => {

registerRoutes(server);

server.all('*', (request, reply) => {
server.get('*', (request, reply) => {
reply.status(404).send({ error: 'Route does not exist' });
});

server.post('*', (request, reply) => {
reply.status(404).send({ error: 'Route does not exist' });
});

Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -738,4 +738,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 2123bfe5ed3b5442a6d71ef2172de1bdfe243f18

COCOAPODS: 1.12.0
COCOAPODS: 1.12.1
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ version: "3.8"

services:
api:
build:
context: .
dockerfile: ./apps/api/Dockerfile
image: superlight/superlight-api:latest
# In case you want to build locally, replace "image:"" with this
# build:
# context: .
# dockerfile: ./apps/api/Dockerfile
ports:
- ${API_PORT}:${API_PORT}
environment:
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,14 @@
cookie "^0.5.0"
fastify-plugin "^4.0.0"

"@fastify/cors@^8.3.0":
version "8.3.0"
resolved "https://registry.yarnpkg.com/@fastify/cors/-/cors-8.3.0.tgz#f03d745731b770793a1a15344da7220ca0d19619"
integrity sha512-oj9xkka2Tg0MrwuKhsSUumcAkfp2YCnKxmFEusi01pjk1YrdDsuSYTHXEelWNW+ilSy/ApZq0c2SvhKrLX0H1g==
dependencies:
fastify-plugin "^4.0.0"
mnemonist "0.39.5"

"@fastify/deepmerge@^1.0.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@fastify/deepmerge/-/deepmerge-1.3.0.tgz#8116858108f0c7d9fd460d05a7d637a13fe3239a"
Expand Down Expand Up @@ -9356,6 +9364,13 @@ mkdirp@^1.0.3, mkdirp@^1.0.4:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

[email protected]:
version "0.39.5"
resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.39.5.tgz#5850d9b30d1b2bc57cc8787e5caa40f6c3420477"
integrity sha512-FPUtkhtJ0efmEFGpU14x7jGbTB+s18LrzRL2KgoWz9YvcY3cPomz8tih01GbHwnGk/OmkOKfqd/RAQoc8Lm7DQ==
dependencies:
obliterator "^2.0.1"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down Expand Up @@ -9725,6 +9740,11 @@ object.values@^1.1.6:
define-properties "^1.1.4"
es-abstract "^1.20.4"

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@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-1.0.0.tgz#4a2accb382278a266848bb1a21439e5fc3cd9881"
Expand Down

0 comments on commit 72aa292

Please sign in to comment.