NextJS app `_next/data` JSON data URLs are showing 404 but when loaded directly in browser json is showing

huangapple go评论64阅读模式
英文:

NextJS app `_next/data` JSON data URLs are showing 404 but when loaded directly in browser json is showing

问题

I have a nextjs (v13) app that is on a self-hosted Kubernetes cluster. NextJS的_data目录中的大部分ajax JSON数据调用都显示为404错误。但是当我将这些URL加载到浏览器中时,没有出现任何404错误。

I am not sure what is happening as in dev version everything looks perfect. 我不确定发生了什么,因为在开发版本中一切都看起来很完美。

You can find the site here https://sportsdemy.com 你可以在这里找到网站:https://sportsdemy.com

I am not sure where to start the debugging. Any hint or direction would be great to have. 我不确定从哪里开始调试。任何提示或方向都将非常有帮助。

Just in case I have pasted my nextjs config file below: 以防万一,我已经粘贴了我的nextjs配置文件如下:

const nextConfig = {
    reactStrictMode: true,
    images: {
        domains: [
            'media.api-sports.io',
            'media-2.api-sports.io',
            'media-3.api-sports.io',
        ],
    },
    experimental: {
        swcMinify: true,
    },
    compiler: {
        styledComponents: true,
    },
    output: 'standalone',
};

module.exports = nextConfig;

404 example

NextJS app `_next/data` JSON data URLs are showing 404 but when loaded directly in browser json is showing

But if you load the URL into your browser, you can load the JSON file just fine. Click here

英文:

I have a nextjs (v13) app that is on a self hosted kubernetes cluster. NextJS most of the ajax json data call form _data directory is showing as 404. But when I load those url into my browser I am not getting any 404 error.

I am not sure what is happening as in dev version everything looks perfect. You can find the site here https://sportsdemy.com

I am not sure where to start the debugging. Any hint or direction would be great to have. Just in case I have pasted my nextjs config file below:

/** @type {import('next').NextConfig} */
const nextConfig = {
	reactStrictMode: true,
	images: {
		domains: [
			'media.api-sports.io',
			'media-2.api-sports.io',
			'media-3.api-sports.io',
		],
	},
	experimental: {
		swcMinify: true,
	},
	compiler: {
		styledComponents: true,
	},
	output: 'standalone',
};

module.exports = nextConfig;

404 example

NextJS app `_next/data` JSON data URLs are showing 404 but when loaded directly in browser json is showing

But if you load the url into your browser. You can load the json file just fine. Click here

答案1

得分: 0

看起来这个问题是因为我没有为 _next/cache 创建一个卷。一旦我将 _next/cache 映射到所有容器都可以共享的卷中,404 问题就消失了。如果有更多更新,我会在这里添加。

英文:

So, looks like this issue was created because I didn't create a volume for _next/cache Once I have mapped _next/cache into a volume which all containers can share the 404 issue was gone.

If I have more update I will add it here.

huangapple
  • 本文由 发表于 2023年5月11日 16:19:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76225508.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定