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

Move App Router client-side constants to separate file #59239

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import {
MIDDLEWARE_FILENAME,
PAGES_DIR_ALIAS,
INSTRUMENTATION_HOOK_FILENAME,
NEXT_DID_POSTPONE_HEADER,
RSC_PREFETCH_SUFFIX,
RSC_SUFFIX,
} from '../lib/constants'
import { NEXT_DID_POSTPONE_HEADER } from '../shared/lib/app-router-client-constants'
import { FileType, fileExists } from '../lib/file-exists'
import { findPagesDir } from '../lib/find-pages-dir'
import loadCustomRoutes, {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/client/components/redirect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { requestAsyncStorage } from './request-async-storage.external'
import type { ResponseCookies } from '../../server/web/spec-extension/cookies'
import { actionAsyncStorage } from './action-async-storage.external'
import { RedirectStatusCode } from '../../shared/lib/constants'
import { RedirectStatusCode } from '../../shared/lib/app-router-client-constants'

const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { urlToUrlWithoutFlightMarker } from '../app-router'
import { callServer } from '../../app-call-server'
import { PrefetchKind } from './router-reducer-types'
import { hexHash } from '../../../shared/lib/hash'
import { NEXT_DID_POSTPONE_HEADER } from '../../../lib/constants'
import { NEXT_DID_POSTPONE_HEADER } from '../../../shared/lib/app-router-client-constants'

export type FetchServerResponseResult = [
flightData: FlightData,
Expand Down
2 changes: 0 additions & 2 deletions packages/next/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export const PRERENDER_REVALIDATE_HEADER = 'x-prerender-revalidate'
export const PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER =
'x-prerender-revalidate-if-generated'

export const NEXT_DID_POSTPONE_HEADER = 'x-nextjs-postponed'

export const RSC_PREFETCH_SUFFIX = '.prefetch.rsc'
export const RSC_SUFFIX = '.rsc'
export const NEXT_DATA_SUFFIX = '.json'
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/lib/redirect-status.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RedirectStatusCode } from '../shared/lib/constants'
import { RedirectStatusCode } from '../shared/lib/app-router-client-constants'

export const allowedStatusCodes = new Set([301, 302, 303, 307, 308])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../../client/components/redirect'
import { renderToReadableStream } from 'react-dom/server.edge'
import { streamToString } from '../stream-utils/node-web-streams-helper'
import { RedirectStatusCode } from '../../shared/lib/constants'
import { RedirectStatusCode } from '../../shared/lib/app-router-client-constants'

export function makeGetServerInsertedHTML({
polyfills,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/base-http/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http'
import type { I18NConfig } from '../config-shared'

import { RedirectStatusCode } from '../../shared/lib/constants'
import { RedirectStatusCode } from '../../shared/lib/app-router-client-constants'
import type { NextApiRequestCookies } from '../api-utils'
import { getCookieParser } from '../api-utils/get-cookie-parser'

Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ import {
APP_PATHS_MANIFEST,
NEXT_BUILTIN_DOCUMENT,
PAGES_MANIFEST,
RedirectStatusCode,
STATIC_STATUS_PAGES,
} from '../shared/lib/constants'
import { RedirectStatusCode } from '../shared/lib/app-router-client-constants'
import { isDynamicRoute } from '../shared/lib/router/utils'
import { checkIsOnDemandRevalidate } from './api-utils'
import { setConfig } from '../shared/lib/runtime-config.external'
Expand Down Expand Up @@ -107,9 +107,9 @@ import {
import {
CACHE_ONE_YEAR,
NEXT_CACHE_TAGS_HEADER,
NEXT_DID_POSTPONE_HEADER,
NEXT_QUERY_PARAM_PREFIX,
} from '../lib/constants'
import { NEXT_DID_POSTPONE_HEADER } from '../shared/lib/app-router-client-constants'
import { normalizeLocalePath } from '../shared/lib/i18n/normalize-locale-path'
import {
NextRequestAdapter,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/lib/router-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import { isPostpone } from './router-utils/is-postpone'
import {
PHASE_PRODUCTION_SERVER,
PHASE_DEVELOPMENT_SERVER,
RedirectStatusCode,
} from '../../shared/lib/constants'
import { RedirectStatusCode } from '../../shared/lib/app-router-client-constants'
import { DevBundlerService } from './dev-bundler-service'
import { type Span, trace } from '../../trace'

Expand Down
6 changes: 6 additions & 0 deletions packages/next/src/shared/lib/app-router-client-constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum RedirectStatusCode {
SeeOther = 303,
TemporaryRedirect = 307,
PermanentRedirect = 308,
}
export const NEXT_DID_POSTPONE_HEADER = 'x-nextjs-postponed'
timneutkens marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 0 additions & 6 deletions packages/next/src/shared/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,3 @@ export const SYSTEM_ENTRYPOINTS = new Set<string>([
CLIENT_STATIC_FILES_RUNTIME_AMP,
CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,
])

export enum RedirectStatusCode {
SeeOther = 303,
TemporaryRedirect = 307,
PermanentRedirect = 308,
}