flutter - 如何找到为 Flutter Web 应用程序提供服务的 URL?
问题描述
我希望我的 webapp 在以下位置可用:
http://example.com/ui/ # My flutter web application
http://example.com/api/... # REST endpoints
如何找到下载我的应用程序的 URL ( http://example.com/ui/
),以便从中生成 URL http://example.com/api/
?
我宁愿不将其烘焙example.com
到 webapp 中,因为我们在 CI 期间部署到许多具有不同域名的集群。
解决方案
import 'dart:html' as html;
...
debugPrint('host=${html.window.location.host + html.window.location.pathname}');
...
推荐阅读
- algorithm - 分析具有以指数方式扩展而不是恒定量的变量的循环
- java - 获取 InvalidDataAccessApiUsageException:使用 ExampleMatcher 时,来自根 %s 的路径“%s”不得跨越循环属性引用
- reactjs - TypeError:无法读取 ReactJS 中未定义的属性“名称”
- powershell - PowerShell - 为什么这不重命名我的文件?
- aws-lambda - API GW V2 HTTP API 和旧版 lambda 授权器
- csv - 如何使用 SPSS 语法使用“获取数据”命令导入 .TSV 文件?
- python - 安装 TensorFlow
- amazon-ec2 - Apache2 服务器和 Superset,502 代理错误,在加载仪表板时从远程服务器读取错误
- c - 逆双正交2.2小波逆DWT实现
- flutter - 提供程序中的颤振使用延迟