Skip to content

Commit f9e2992

Browse files
feat: add suffix to rsc txt files for easy routing
* enables easy handling for cdns or proxies to identify rsc payloads and route them correctly beside other txt files
1 parent 3dafab9 commit f9e2992

File tree

9 files changed

+7004
-6939
lines changed

9 files changed

+7004
-6939
lines changed

packages/next/src/client/components/router-reducer/fetch-server-response.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ export async function fetchServerResponse(
180180
// to the request.
181181
url = new URL(url)
182182
if (url.pathname.endsWith('/')) {
183-
url.pathname += 'index.txt'
183+
url.pathname += 'index.rsc.txt'
184184
} else {
185-
url.pathname += '.txt'
185+
url.pathname += '.rsc.txt'
186186
}
187187
}
188188
}

packages/next/src/client/route-params.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ export function urlToUrlWithoutFlightMarker(url: URL): URL {
154154
if (process.env.NODE_ENV === 'production') {
155155
if (
156156
process.env.__NEXT_CONFIG_OUTPUT === 'export' &&
157-
urlWithoutFlightParameters.pathname.endsWith('.txt')
157+
urlWithoutFlightParameters.pathname.endsWith('.rsc.txt')
158158
) {
159159
const { pathname } = urlWithoutFlightParameters
160-
const length = pathname.endsWith('/index.txt') ? 10 : 4
161-
// Slice off `/index.txt` or `.txt` from the end of the pathname
160+
const length = pathname.endsWith('/index.rsc.txt') ? 14 : 8
161+
// Slice off `/index.rsc.txt` or `.rsc.txt` from the end of the pathname
162162
urlWithoutFlightParameters.pathname = pathname.slice(0, -length)
163163
}
164164
}

packages/next/src/export/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ async function exportAppImpl(
846846
outDir,
847847
`${route}${
848848
subFolders && route !== '/index' ? `${sep}index` : ''
849-
}.txt`
849+
}.rsc.txt`
850850
)
851851
: join(pagesDataDir, `${route}.json`)
852852

test/integration/app-dir-export/test/utils.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ export const expectedWhenTrailingSlashTrue = [
6565
'another/first/__next.another.$d$slug.txt',
6666
'another/first/__next.another.txt',
6767
'another/first/index.html',
68-
'another/first/index.txt',
68+
'another/first/index.rsc.txt',
6969
'another/index.html',
70-
'another/index.txt',
70+
'another/index.rsc.txt',
7171
'another/second/__next._full.txt',
7272
'another/second/__next._index.txt',
7373
'another/second/__next._tree.txt',
7474
'another/second/__next.another.$d$slug.__PAGE__.txt',
7575
'another/second/__next.another.$d$slug.txt',
7676
'another/second/__next.another.txt',
7777
'another/second/index.html',
78-
'another/second/index.txt',
78+
'another/second/index.rsc.txt',
7979
'api/json',
8080
'api/txt',
8181
'client/__next._full.txt',
@@ -84,17 +84,17 @@ export const expectedWhenTrailingSlashTrue = [
8484
'client/__next.client.__PAGE__.txt',
8585
'client/__next.client.txt',
8686
'client/index.html',
87-
'client/index.txt',
87+
'client/index.rsc.txt',
8888
'favicon.ico',
8989
'image-import/__next._full.txt',
9090
'image-import/__next._index.txt',
9191
'image-import/__next._tree.txt',
9292
'image-import/__next.image-import.__PAGE__.txt',
9393
'image-import/__next.image-import.txt',
9494
'image-import/index.html',
95-
'image-import/index.txt',
95+
'image-import/index.rsc.txt',
9696
'index.html',
97-
'index.txt',
97+
'index.rsc.txt',
9898
'robots.txt',
9999
]
100100

@@ -122,22 +122,22 @@ const expectedWhenTrailingSlashFalse = [
122122
'_not-found/__next._not-found.txt',
123123
'_not-found/__next._tree.txt',
124124
'another.html',
125-
'another.txt',
125+
'another.rsc.txt',
126126
'another/__next._full.txt',
127127
'another/__next._index.txt',
128128
'another/__next._tree.txt',
129129
'another/__next.another.__PAGE__.txt',
130130
'another/__next.another.txt',
131131
'another/first.html',
132-
'another/first.txt',
132+
'another/first.rsc.txt',
133133
'another/first/__next._full.txt',
134134
'another/first/__next._index.txt',
135135
'another/first/__next._tree.txt',
136136
'another/first/__next.another.$d$slug.__PAGE__.txt',
137137
'another/first/__next.another.$d$slug.txt',
138138
'another/first/__next.another.txt',
139139
'another/second.html',
140-
'another/second.txt',
140+
'another/second.rsc.txt',
141141
'another/second/__next._full.txt',
142142
'another/second/__next._index.txt',
143143
'another/second/__next._tree.txt',
@@ -147,22 +147,22 @@ const expectedWhenTrailingSlashFalse = [
147147
'api/json',
148148
'api/txt',
149149
'client.html',
150-
'client.txt',
150+
'client.rsc.txt',
151151
'client/__next._full.txt',
152152
'client/__next._index.txt',
153153
'client/__next._tree.txt',
154154
'client/__next.client.__PAGE__.txt',
155155
'client/__next.client.txt',
156156
'favicon.ico',
157157
'image-import.html',
158-
'image-import.txt',
158+
'image-import.rsc.txt',
159159
'image-import/__next._full.txt',
160160
'image-import/__next._index.txt',
161161
'image-import/__next._tree.txt',
162162
'image-import/__next.image-import.__PAGE__.txt',
163163
'image-import/__next.image-import.txt',
164164
'index.html',
165-
'index.txt',
165+
'index.rsc.txt',
166166
'robots.txt',
167167
]
168168

0 commit comments

Comments
 (0)