From 249a4e683ad27b5cce6c6b651be40a30fe7eedab Mon Sep 17 00:00:00 2001 From: Radu-Cristian Popa Date: Fri, 23 Feb 2024 07:42:38 +0200 Subject: [PATCH] feat(backend): add cors for open payments server #2438 --- packages/backend/package.json | 2 ++ packages/backend/src/app.ts | 2 ++ pnpm-lock.yaml | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/packages/backend/package.json b/packages/backend/package.json index 65fb4f14c9..34e6519e58 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -23,6 +23,7 @@ "@graphql-codegen/typescript-resolvers": "4.0.5", "@types/koa": "2.14.0", "@types/koa-bodyparser": "^4.3.12", + "@types/koa__cors": "^5.0.0", "@types/koa__router": "^12.0.4", "@types/lodash": "^4.14.202", "@types/luxon": "^3.4.2", @@ -55,6 +56,7 @@ "@interledger/openapi": "1.2.1", "@interledger/pay": "0.4.0-alpha.9", "@interledger/stream-receiver": "^0.3.3-alpha.3", + "@koa/cors": "^5.0.0", "@koa/router": "^12.0.0", "@opentelemetry/api": "^1.6.0", "@opentelemetry/exporter-metrics-otlp-grpc": "^0.43.0", diff --git a/packages/backend/src/app.ts b/packages/backend/src/app.ts index ed646ec5e8..e5adc65ca6 100644 --- a/packages/backend/src/app.ts +++ b/packages/backend/src/app.ts @@ -9,6 +9,7 @@ import Koa, { DefaultState } from 'koa' import bodyParser from 'koa-bodyparser' import { Logger } from 'pino' import Router from '@koa/router' +import cors from '@koa/cors' import { ApolloServer } from '@apollo/server' import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer' import { koaMiddleware } from '@as-integrations/koa' @@ -583,6 +584,7 @@ export class App { walletAddressRoutes.get ) + koa.use(cors()) koa.use(router.routes()) this.openPaymentsServer = koa.listen(port) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6cc058543c..6ee2787438 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -283,6 +283,9 @@ importers: '@interledger/stream-receiver': specifier: ^0.3.3-alpha.3 version: 0.3.3-alpha.3 + '@koa/cors': + specifier: ^5.0.0 + version: 5.0.0 '@koa/router': specifier: ^12.0.0 version: 12.0.0 @@ -404,6 +407,9 @@ importers: '@types/koa-bodyparser': specifier: ^4.3.12 version: 4.3.12 + '@types/koa__cors': + specifier: ^5.0.0 + version: 5.0.0 '@types/koa__router': specifier: ^12.0.4 version: 12.0.4