From 661d9d2e56ef672d5dea6259621ad6de845c8c1e Mon Sep 17 00:00:00 2001 From: Wanjohi Date: Tue, 10 Jun 2025 15:34:21 +0300 Subject: [PATCH] fix: Fix cookie issue --- infra/api.ts | 9 +++++++++ packages/functions/src/api/steam.ts | 2 +- sst-env.d.ts | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/infra/api.ts b/infra/api.ts index 9800d11d..a93e8539 100644 --- a/infra/api.ts +++ b/infra/api.ts @@ -5,12 +5,21 @@ import { domain } from "./dns"; import { secret } from "./secret"; import { postgres } from "./postgres"; +const urls = new sst.Linkable("Urls", { + properties: { + api: `https://api.${domain}`, + auth: `https://auth.${domain}`, + site: $dev ? "http://localhost:3000" : `https://console.${domain}`, + } +}) + const apiFn = new sst.aws.Function("ApiFn", { vpc, handler: "packages/functions/src/api/index.handler", streaming: !$dev, link: [ bus, + urls, auth, postgres, secret.SteamApiKey, diff --git a/packages/functions/src/api/steam.ts b/packages/functions/src/api/steam.ts index 903ad658..0e2cc806 100644 --- a/packages/functions/src/api/steam.ts +++ b/packages/functions/src/api/steam.ts @@ -236,7 +236,7 @@ export namespace SteamApi { setCookie(c, "user_id", user.id); - const returnUrl = `${new URL(c.req.url).origin}/steam/callback/${userID}` + const returnUrl = `${new URL(Resource.Urls.api).origin}/steam/callback/${userID}` const params = new URLSearchParams({ 'openid.ns': 'http://specs.openid.net/auth/2.0', diff --git a/sst-env.d.ts b/sst-env.d.ts index 95b32621..40b884bc 100644 --- a/sst-env.d.ts +++ b/sst-env.d.ts @@ -105,6 +105,12 @@ declare module "sst" { "name": string "type": "sst.aws.Bucket" } + "Urls": { + "api": string + "auth": string + "site": string + "type": "sst.sst.Linkable" + } "VPC": { "bastion": string "type": "sst.aws.Vpc"