问题描述
我正在尝试部署到IIS。不是根目录,而是子目录。 工作正常:
- 编辑web / index.html,将
<base href="/">
更改为<base href="/ChangeTag/">
- 运行Flutter构建Web命令
- build / web / index.html可以,并进行新的更改。
完美!
但是,当我尝试使用localhost进行调试时:未找到网页-错误404
我想要的是自动部署在wwwroot的子文件夹中,并且也执行本地测试,而无需多次修改index.html
是否可以在Angular中执行类似操作,使用代理,使用其他构建配置等?
谢谢
解决方法
在将flutter和dark升级到当前版本(bet通道)后,我遇到了类似的问题,我的意思是它在调试模式下很好,并且在构建版本上不起作用。
我做了什么?我只是评论了<base href="/">
文件(位于index.html
文件夹中)的这一<your_app_folder_name>/web
行,并且两者(调试和发布版本)都恢复了正常工作。
我确实通过更改行来发表评论
<base href="/">
到
<!-- <base href="/"> -->
进行更改,然后:尝试运行flutter build web
命令,将位于web
路径的生成的<your_app_folder_name>/build/
文件夹复制到该文件夹的任何子文件夹(例如<your_websrv_root>/webtestfolder
)。您的网络服务器,它将在浏览器的地址http://webtestfolder
上运行。
答案在 web 文件夹(不是 /build/web)上的 index.html 文件中
<!DOCTYPE html>
<html>
<head>
<!--
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:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
-->
<base href="/sub-folder/">
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">