Skip to content

Commit f261e77

Browse files
authored
hotfix: attempt to fix vercel region (access fetch during initial build) (#7355)
1 parent 094fa47 commit f261e77

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

apps/site/next-data/blogData.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ import {
33
IS_DEV_ENV,
44
NEXT_DATA_URL,
55
VERCEL_ENV,
6+
VERCEL_REGION,
67
} from '@/next.constants.mjs';
78
import type { BlogPostsRSC } from '@/types';
89

910
const getBlogData = (cat: string, page?: number): Promise<BlogPostsRSC> => {
11+
const IS_NOT_VERCEL_RUNTIME_ENV =
12+
(!IS_DEV_ENV && VERCEL_ENV && !VERCEL_REGION) ||
13+
(!IS_DEV_ENV && !VERCEL_ENV);
14+
1015
// When we're using Static Exports the Next.js Server is not running (during build-time)
1116
// hence the self-ingestion APIs will not be available. In this case we want to load
1217
// the data directly within the current thread, which will anyways be loaded only once
1318
// We use lazy-imports to prevent `provideBlogData` from executing on import
14-
if (ENABLE_STATIC_EXPORT || (VERCEL_ENV !== 'production' && !IS_DEV_ENV)) {
19+
if (ENABLE_STATIC_EXPORT || IS_NOT_VERCEL_RUNTIME_ENV) {
1520
return import('@/next-data/providers/blogData').then(
1621
({ provideBlogPosts, providePaginatedBlogPosts }) =>
1722
page ? providePaginatedBlogPosts(cat, page) : provideBlogPosts(cat)

apps/site/next-data/downloadSnippets.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
IS_DEV_ENV,
44
NEXT_DATA_URL,
55
VERCEL_ENV,
6+
VERCEL_REGION,
67
} from '@/next.constants.mjs';
78
import { availableLocaleCodes } from '@/next.locales.mjs';
89
import type { DownloadSnippet } from '@/types';
@@ -14,11 +15,15 @@ const getDownloadSnippets = (lang: string): Promise<Array<DownloadSnippet>> => {
1415
return Promise.resolve([]);
1516
}
1617

18+
const IS_NOT_VERCEL_RUNTIME_ENV =
19+
(!IS_DEV_ENV && VERCEL_ENV && !VERCEL_REGION) ||
20+
(!IS_DEV_ENV && !VERCEL_ENV);
21+
1722
// When we're using Static Exports the Next.js Server is not running (during build-time)
1823
// hence the self-ingestion APIs will not be available. In this case we want to load
1924
// the data directly within the current thread, which will anyways be loaded only once
2025
// We use lazy-imports to prevent `provideBlogData` from executing on import
21-
if (ENABLE_STATIC_EXPORT || (VERCEL_ENV !== 'production' && !IS_DEV_ENV)) {
26+
if (ENABLE_STATIC_EXPORT || IS_NOT_VERCEL_RUNTIME_ENV) {
2227
return import('@/next-data/providers/downloadSnippets').then(
2328
({ default: provideDownloadSnippets }) => provideDownloadSnippets(lang)!
2429
);

apps/site/next-data/releaseData.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ import {
33
IS_DEV_ENV,
44
NEXT_DATA_URL,
55
VERCEL_ENV,
6+
VERCEL_REGION,
67
} from '@/next.constants.mjs';
78
import type { NodeRelease } from '@/types';
89

910
const getReleaseData = (): Promise<Array<NodeRelease>> => {
11+
const IS_NOT_VERCEL_RUNTIME_ENV =
12+
(!IS_DEV_ENV && VERCEL_ENV && !VERCEL_REGION) ||
13+
(!IS_DEV_ENV && !VERCEL_ENV);
14+
1015
// When we're using Static Exports the Next.js Server is not running (during build-time)
1116
// hence the self-ingestion APIs will not be available. In this case we want to load
1217
// the data directly within the current thread, which will anyways be loaded only once
1318
// We use lazy-imports to prevent `provideBlogData` from executing on import
14-
if (ENABLE_STATIC_EXPORT || (VERCEL_ENV !== 'production' && !IS_DEV_ENV)) {
19+
if (ENABLE_STATIC_EXPORT || IS_NOT_VERCEL_RUNTIME_ENV) {
1520
return import('@/next-data/providers/releaseData').then(
1621
({ default: provideReleaseData }) => provideReleaseData()
1722
);

apps/site/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/// <reference types="next/navigation-types/compat/navigation" />
44

55
// NOTE: This file should not be edited
6-
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
6+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

0 commit comments

Comments
 (0)