Skip to content

Commit

Permalink
Fix: Error Fetching _devpagesmanifest.json #17274 (#60349)
Browse files Browse the repository at this point in the history
Closes NEXT-
Fixes #17274 Error Fetching _devpagesmanfest.json

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
itz-Me-Pj and ijjk committed Feb 6, 2024
1 parent 875dee9 commit 98232c8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/next/src/client/page-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export default class PageLoader {
return window.__DEV_PAGES_MANIFEST.pages
} else {
this.promisedDevPagesManifest ||= fetch(
`${this.assetPrefix}/_next/static/development/${DEV_CLIENT_PAGES_MANIFEST}`
`${this.assetPrefix}/_next/static/development/${DEV_CLIENT_PAGES_MANIFEST}`,
{ credentials: 'same-origin' }
)
.then((res) => res.json())
.then((manifest: { pages: string[] }) => {
Expand Down Expand Up @@ -98,7 +99,8 @@ export default class PageLoader {
// TODO: Decide what should happen when fetching fails instead of asserting
// @ts-ignore
this.promisedMiddlewareMatchers = fetch(
`${this.assetPrefix}/_next/static/${this.buildId}/${DEV_MIDDLEWARE_MANIFEST}`
`${this.assetPrefix}/_next/static/${this.buildId}/${DEV_MIDDLEWARE_MANIFEST}`,
{ credentials: 'same-origin' }
)
.then((res) => res.json())
.then((matchers: MiddlewareMatcher[]) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/client/route-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export function createRouteLoader(assetPrefix: string): RouteLoader {

styleSheets.set(
href,
(prom = fetch(href)
(prom = fetch(href, { credentials: 'same-origin' })
.then((res) => {
if (!res.ok) {
throw new Error(`Failed to load stylesheet: ${href}`)
Expand Down
20 changes: 20 additions & 0 deletions test/integration/dynamic-routing/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,26 @@ function runTests({ dev }) {
}
`
)
await check(async () => {
const response = await fetchViaHTTP(
appPort,
'/_next/static/development/_devPagesManifest.json',
undefined,
{
credentials: 'same-origin',
}
)

// Check if the response was successful (status code in the range 200-299)
if (!response.ok) {
return 'fail'
}

const contents = await response.text()
const containsAddedLater = contents.includes('added-later')

return containsAddedLater ? 'success' : 'fail'
}, 'success')

await check(async () => {
const contents = await renderViaHTTP(
Expand Down

0 comments on commit 98232c8

Please sign in to comment.