You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js静态导出页面刷新时出现间歇性Nginx 503静态Chunk错误

Next.js静态导出部署后刷新/导航出现Nginx 503静态Chunk错误

我正在开发一个采用静态导出的Next.js网站,配置如下:

const nextConfig = {
    output: 'export',
    distDir: 'dist',
    images: {
        unoptimized: true
    }
}

网站部署在OpenShift上,使用Docker和Nginx提供服务,静态文件输出到dist目录,测试环境为mysite-test.com和mysite-stage.com。

问题现象:首次访问页面可正常渲染,但后续导航或刷新其他页面时,会出现多个静态Chunk的503错误,这些错误是Nginx提供文件时产生的,如需Nginx配置我可以提供。

项目逻辑:应用通过无头CMS获取页面核心数据,单个页面渲染时会发起两个API调用获取文档列表。

已尝试的排查操作:

  • 排查过缓存相关问题
  • 尝试使用standalone导出,结果出现403错误
  • 调整过'use client'的位置
  • 用React包裹组件
  • 使用isLoading状态在数据加载前渲染骨架屏,确保数据加载完成后再渲染内容

以下是新项目结构的layout.tsx文件:

import './globals.css';
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import Header from './header/page';
import Footer from './footer/page';
import Link from 'next/link';
import styles from './Styles.module.css';
import Head from 'next/head';
import { Suspense } from 'react';
import { Skeleton } from '@mui/material';

const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
  title: 'My Site',
  description: 'My Site Description',
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en" id="page-container">
      <Head>
        <link rel="icon" href="./favicon.ico" sizes="any" />
      </Head>
      <body className={`${inter.className} `}>
        <div className="w-screen bg-white">
          <Link
            href="#main"
            className={styles.stmcl}
            style={{ width: '300px' }}
          >
            Skip To Content
          </Link>
        </div>
        <div>
          <div className="bg-white" style={{ display: 'block' }}>
            <Suspense
              fallback={<Skeleton width={1500} height={1500}></Skeleton>}
            >
              <Header />
              <main id="content" className="min-h-[40em] w-full">
                {children}
              </main>
            </Suspense>
          </div>
          <Suspense fallback={<Skeleton width={1500} height={1500}></Skeleton>}>
            <Footer />
          </Suspense>
        </div>
      </body>
    </html>
  );
}

本地环境首次加载疑似存在缓存问题,部署后仅在页面刷新时出现间歇性错误,我可以提供其他相关代码协助排查。


内容的提问来源于stack exchange,提问作者Before The Empire

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 13:43:14