Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetBaseUrl should take in account values from the env #1063

Open
krzysztofwolski opened this issue Oct 13, 2023 · 0 comments
Open

GetBaseUrl should take in account values from the env #1063

krzysztofwolski opened this issue Oct 13, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@krzysztofwolski
Copy link
Member

Thanks Djkato from discord, issue has been found in function providing base URL: https://discord.com/channels/864066819866624010/1161653605581991996

apps/emails-and-messages/src/modules/trpc/trpc-client.ts

function getBaseUrl() {
  if (typeof windoiws !== "undefined") return "";
  if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`
//here
  if (process.env.APP_API_BASE_URL) return process.env.APP_API_BASE_URL

return `http://localhost:${process.env.PORT ?? 3000}`
}

apps/emails-and-messages/src/lib/get-base-url.ts

export const getBaseUrl = (headers: { [name: string]: string | string[] | undefined }): string => {
  const { host, "x-forwarded-proto": xForwardedProto = "http" } = headers;

  if ((host?.includes("localhost") || host?.includes("127.0.0.1")) && process.env.APP_API_BASE_URL) return process.env.APP_API_BASE_URL

//...
@krzysztofwolski krzysztofwolski added the bug Something isn't working label Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant