diff --git a/apps/api/src/billing/controllers/checkout/checkout.controller.ts b/apps/api/src/billing/controllers/checkout/checkout.controller.ts index 160d5adf2..9a7f45889 100644 --- a/apps/api/src/billing/controllers/checkout/checkout.controller.ts +++ b/apps/api/src/billing/controllers/checkout/checkout.controller.ts @@ -1,3 +1,4 @@ +import { LoggerService } from "@akashnetwork/logging"; import type { Context } from "hono"; import { singleton } from "tsyringe"; @@ -8,6 +9,8 @@ import { StripeWebhookService } from "@src/billing/services/stripe-webhook/strip @singleton() export class CheckoutController { + private readonly logger = LoggerService.forContext(CheckoutController.name); + constructor( private readonly authService: AuthService, private readonly checkoutService: CheckoutService, @@ -35,6 +38,9 @@ export class CheckoutController { if (error.message === "Price invalid") { return c.redirect(`${redirectUrl}?invalid-price=true`); } + + this.logger.error(error); + return c.redirect(`${redirectUrl}?unknown-error=true`); } } diff --git a/apps/deploy-web/src/pages/api/proxy/[...path].ts b/apps/deploy-web/src/pages/api/proxy/[...path].ts index 6f95ec120..a77441f78 100644 --- a/apps/deploy-web/src/pages/api/proxy/[...path].ts +++ b/apps/deploy-web/src/pages/api/proxy/[...path].ts @@ -1,17 +1,17 @@ import { getSession } from "@auth0/nextjs-auth0"; import httpProxy from "http-proxy"; +import type { NextApiHandler } from "next"; import { serverEnvConfig } from "@src/config/server-env.config"; -export default async (req, res) => { - // removes the api prefix from url - req.url = req.url.replace(/^\/api\/proxy/, ""); +const proxyToApi: NextApiHandler = async (req, res) => { + req.url = req.url?.replace(/^\/api\/proxy/, ""); console.log("proxy:", req.url); const session = await getSession(req, res); - // don't forward the cookies to the target server - req.headers.cookie = ""; + const cfClearanceCookie = req.cookies["cf_clearance"]; + req.headers.cookie = cfClearanceCookie ? `cf_clearance=${cfClearanceCookie}` : ""; if (session?.accessToken) { req.headers.authorization = `Bearer ${session.accessToken}`; @@ -41,3 +41,5 @@ export const config = { bodyParser: false } }; + +export default proxyToApi;