Skip to content

Commit

Permalink
Merge pull request #458 from mwskwong/bugfix/457-siteurl-is-always-ht…
Browse files Browse the repository at this point in the history
…tplocalhost3000-when-accessed-on-the-client-side

Bugfix/457 siteurl is always httplocalhost3000 when accessed on the client side
  • Loading branch information
mwskwong committed Aug 27, 2024
2 parents db2276b + ff56c77 commit 6f26241
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/constants/site-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { capitalize } from 'lodash-es';

export const siteUrl = (() => {
const localUrl = `http://localhost:${process.env.PORT ?? 3000}`;
if (!process.env.VERCEL) return localUrl;
if (!process.env.NEXT_PUBLIC_VERCEL_ENV) return localUrl;

const previewDeploymentHostname =
process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL ??
Expand Down
3 changes: 1 addition & 2 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const VercelUrlSchema = pipe(string(), nonEmpty());

const EnvSchema = object({
DATABASE_URL: pipe(string(), url()),
VERCEL: optional(literal('1')),
VERCEL_ENV: VercelEnvSchema,
CONTENTFUL_ENVIRONMENT: (() => {
switch (process.env.VERCEL_ENV) {
Expand Down Expand Up @@ -61,7 +60,7 @@ if (process.env.npm_lifecycle_event !== 'lint') {
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace -- this is a valid namespace form @types/node
// eslint-disable-next-line @typescript-eslint/no-namespace -- this is a valid namespace from @types/node
namespace NodeJS {
// eslint-disable-next-line @typescript-eslint/no-empty-interface -- ProcessEnv is an interface, extending it here
interface ProcessEnv extends InferOutput<typeof EnvSchema> {}
Expand Down

1 comment on commit 6f26241

@vercel
Copy link

@vercel vercel bot commented on 6f26241 Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.