diff --git a/packages/core/package.json b/packages/core/package.json index 21f7bdb16..85b930bbf 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -16,6 +16,7 @@ "@logto/schemas": "^1.0.1", "dayjs": "^1.10.5", "dotenv": "^10.0.0", + "got": "^11.8.2", "koa": "^2.13.1", "koa-logger": "^3.2.1", "koa-mount": "^4.0.0", diff --git a/packages/core/src/init/router.ts b/packages/core/src/init/router.ts index 1b7246741..f8d722d6e 100644 --- a/packages/core/src/init/router.ts +++ b/packages/core/src/init/router.ts @@ -1,11 +1,17 @@ +import got from 'got'; import Koa from 'koa'; import Router from 'koa-router'; +import { promisify } from 'util'; +import stream from 'stream'; import { signInRoute } from '../consts'; +import { getEnv } from '../utils'; +const pipeline = promisify(stream.pipeline); const router = new Router(); -router.get(signInRoute, (ctx) => { - ctx.body = 'Signing in'; +router.get(new RegExp(`^${signInRoute}(?:/|$)`), async (ctx) => { + // CAUTION: this is for dev purpose only, add a switch if needed + await pipeline(got.stream.get(getEnv('PLAYGROUND_URL')), ctx.res); }); export default function initRouter(app: Koa): void { diff --git a/packages/core/yarn.lock b/packages/core/yarn.lock index 1a0580ccc..f6cd55cd8 100644 --- a/packages/core/yarn.lock +++ b/packages/core/yarn.lock @@ -2579,7 +2579,7 @@ globby@^9.2.0: pify "^4.0.1" slash "^2.0.0" -got@^11.7.0: +got@^11.7.0, got@^11.8.2: version "11.8.2" resolved "https://registry.yarnpkg.com/got/-/got-11.8.2.tgz#7abb3959ea28c31f3576f1576c1effce23f33599" integrity sha512-D0QywKgIe30ODs+fm8wMZiAcZjypcCodPNuMz5H9Mny7RJ+IjJ10BdmGW7OM7fHXP+O7r6ZwapQ/YQmMSvB0UQ==