Skip to content

Fix catch-all route serving HTML for API requests#2885

Draft
Copilot wants to merge 2 commits intodevelopfrom
copilot/fix-env-js-loading-error
Draft

Fix catch-all route serving HTML for API requests#2885
Copilot wants to merge 2 commits intodevelopfrom
copilot/fix-env-js-loading-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 24, 2025

The catch-all route app.get('*', ...) was matching /api/env.js and other API endpoints, serving index.html instead of route handlers. Browsers received HTML when expecting JavaScript, causing SyntaxError: Unexpected token '<'.

Changes

  • Added path check to catch-all route to skip /api/* requests, allowing them to reach registered handlers or error middleware
app.get('*', (req, res, next) => {
  // Don't serve index.html for API routes
  if (req.path.startsWith('/api/')) {
    return next();
  }
  // ... serve index.html for SPA routes
});

This preserves SPA routing for frontend paths while ensuring API routes return proper JSON/JavaScript responses.

Original prompt

This section details on the original issue you should resolve

<issue_title>最新版 docker 镜像,访问首页加载 env.js 报错,导致页面空白</issue_title>
<issue_description>### Qinglong version

2.20.0

Steps to reproduce

Docker arm64 拉取最新镜像,访问页面空白,查看是前端 JS 加载报错

Image

What is expected?

正在进入登陆页面

What is actually happening?

页面空白,无法加载

System Info

 chrome 143.0.7499.41

Any additional comments?

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

@whyour 贴个图吧 @whyour docker 容器启动成功了吗

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
qinglong Ready Ready Preview, Comment Dec 24, 2025 8:45am
qinglong-back Ready Ready Preview, Comment Dec 24, 2025 8:45am

…utes

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix env.js loading error in latest docker image Fix catch-all route serving HTML for API requests Dec 24, 2025
Copilot AI requested a review from whyour December 24, 2025 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

最新版 docker 镜像,访问首页加载 env.js 报错,导致页面空白

2 participants