javascript - "_ssgManifest.js" & _buildManifest.js missing from a nextjs app hosted on Google Cloud Pl

sometimes the console shows these errors on opening the websiteGET .js[HTTP3 404 Not Found 311ms]GET

sometimes the console shows these errors on opening the website

GET .js
[HTTP/3 404 Not Found 311ms]

GET .js
[HTTP/3 404 Not Found 334ms]

Loading failed for the <script> with source “.js”. 1434-247:1:1
Loading failed for the <script> with source “.js”.

the app does use ISR and that seems to be working, it does get updated, what do these files do? what could happen if they are missing?

  • "react": "17.0.2"
  • "next": "10.1.3",
  • "node" "15.1.2"

sometimes the console shows these errors on opening the website

GET https://example./subpath/_next/static/9ufj5kFJf/_buildManifest.js
[HTTP/3 404 Not Found 311ms]

GET https://example./subpath/_next/static/9ufj5kFJf/_ssgManifest.js
[HTTP/3 404 Not Found 334ms]

Loading failed for the <script> with source “https://example./subpath/_next/static/9ufj5kFJf/_buildManifest.js”. 1434-247:1:1
Loading failed for the <script> with source “https://example./subpath/_next/static/9ufj5kFJf/_ssgManifest.js”.

the app does use ISR and that seems to be working, it does get updated, what do these files do? what could happen if they are missing?

  • "react": "17.0.2"
  • "next": "10.1.3",
  • "node" "15.1.2"
Share Improve this question edited Jul 30, 2021 at 19:38 Gourav B 9826 silver badges19 bronze badges asked Jul 23, 2021 at 15:46 ashish_armaashish_arma 3051 gold badge3 silver badges9 bronze badges 1
  • 1 I think this github issue may help you. Also you have mentioned that you have hosted the application on gcloud. Can you please add more details like which infrastructure in Google Cloud Platform (Google App Engine/ Google Kubernetes Engine/ Google Compute Engine or anything else) you are using to host the Next.js application and any specific documentation you are following? – Prabir Commented Jul 29, 2021 at 12:55
Add a ment  | 

3 Answers 3

Reset to default 1

I had the same problem with GCP (Kubernetes engine) with pods count > 1. I resolved the issue by restarting the deployment (all pods).

On that Github issue @Prabir linked to in a ment, someone posted a way to use the generateBuildId function within the Next.js config file:

const execSync = require("child_process").execSync;

const lastCommitCommand = "git rev-parse HEAD";

module.exports = {
  async generateBuildId() {
    return execSync(lastCommitCommand).toString().trim();
  },
};

I work with an app that uses some bination of AWS CodeBuild and Docker images, which prevents direct access to all the git mands so that snippet above didn't work. But using CODEBUILD_BUILD_ID or really any environment variable (unique to either that mit or the build itself) did. I'm not as familiar with the GCP-equivalents but this Cloud Build Docs page makes it seem like $COMMIT_SHA would be a good option to try.

Mine might be nieche but I am posting it in case it will help someone since I've been pulling hair over it (and I am bald).

I had a file called middleware.ts that had the following code:

import { NextResponse } from 'next/server';

// Convert all paths to lower case
const Middleware = (req: any) => {
  if (req.nextUrl.pathname === req.nextUrl.pathname.toLowerCase())
    return NextResponse.next();

  return NextResponse.redirect(new URL(req.nextUrl.origin + req.nextUrl.pathname.toLowerCase()));
};

export default Middleware;

once I removed it the problem got fixed.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745305852a4621704.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信