子文件夹中的 Flutter Web 应用程序仅 returns 到根页面

Flutter web app in a subfolder just returns to the root page

我在 suragch.dev 有一个 Flutter 组合应用程序,然后在 apps 子文件夹中有一些其他 Web 应用程序。但是,当我推送更改并尝试访问子文件夹中的新 Flutter 应用程序时

https://suragch.dev/apps/mongoleditor/

它 returns 到 Flutter 根页面。过去我没有这个问题。事实上,应用程序文件夹中的另一个 flutter 应用程序运行良好:

https://suragch.dev/apps/mongolcode/

我该如何解决这个问题?

我找到了答案,会在下面添加。

现在,当您构建不从根目录提供服务的 Flutter Web 应用程序时,您需要更改应用程序的 index.html 文件中的基础。该文件的注释中对此进行了描述:

If you are serving your web app in a path other than the root, change the href value below to reflect the base path you are serving from.

The path provided below has to start and end with a slash "/" in order for it to work correctly.

For more details:

所以只要改变这个:

<base href="/">

对此:

<base href="https://suragch.dev/apps/mongoleditor/">