Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 设置server.baseUrl后本地无法预览 #6253

Closed
shen774411223d opened this issue Sep 24, 2024 · 1 comment
Closed

[Bug]: 设置server.baseUrl后本地无法预览 #6253

shen774411223d opened this issue Sep 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@shen774411223d
Copy link

Version

System:
    OS: Windows 11 10.0.22631
    CPU: (32) x64 Intel(R) Core(TM) i9-14900HX
    Memory: 1.79 GB / 15.63 GB
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @modern-js/app-tools: 2.59.0 => 2.59.0
    @modern-js/eslint-config: 2.59.0 => 2.59.0
    @modern-js/runtime: 2.59.0 => 2.59.0
    @modern-js/tsconfig: 2.59.0 => 2.59.0

Details

在config.js文件中设置了server.baseUrl = '/sec'后执行npm run dev 在控制台输出 localhost:8080/sec 在浏览器打开该链接发现无法正常展示页面

// config.js 完全配置
export default defineConfig({
  server: {
    baseUrl: '/sec',
  },
  runtime: {
    router: {
      supportHtml5History: false,
    },
  },
  output: {
    assetPrefix: '/sec',
    enableCssModuleTSDeclaration: true,
    distPath: {
      js: 'assets',
      css: 'assets',
      html: '',
    },
  },
  html: {
    disableHtmlFolder: true,
  },
  plugins: [
    appTools({
      bundler: 'rspack', // Set to 'webpack' to enable webpack
    }),
  ],
});

image
network中页面虽然请求成功但显示了空白页

Reproduce link

none

Reproduce Steps

  1. 基于官网的项目命令
  2. 使用约定式路由
@shen774411223d shen774411223d added the bug Something isn't working label Sep 24, 2024
@caohuilin
Copy link
Member

supportHtml5History 设置为 false 和 server.baseUrl 不支持同时使用,因为 supportHtml5History 设置为 false 时,会使用 hashRouter,同时传递 server.baseUrl 的 basename 会造成路由冲突,如果一定要使用 hash 路由,可以参考这个 issue 调整一下代码实现 remix-run/react-router#8427 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants