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

Add: Host Redirect #1455

Merged
merged 1 commit into from
May 26, 2024
Merged

Add: Host Redirect #1455

merged 1 commit into from
May 26, 2024

Conversation

AmosHuKe
Copy link
Member

@AmosHuKe AmosHuKe commented May 24, 2024

https://github.com/cfug/team/issues/54

一个临时的重定向工具。
由于 OSS 部分限制的问题,
无法将大量重定向逻辑在服务端直接使用(类似 Nginx、Apache 等),

所有无法访问的链接会被重定向至 404 页,
该工具利用 404 页,将 firebase.json 内的重定向逻辑运行在 404 页面。

关于 firebase.json 内重定向的相关资料:

https://firebase.google.cn/docs/hosting/full-config?hl=zh-cn#redirects

host-redirect.min.js 做了什么?

解析 firebase.json 内重定向 source 和 regex 对应的 globRE2 规则,
并生成新的路由进行重定向。

host-redirect.min.js 会在何时生成?

当发生以下情况时,会自动执行 CI 并生成 host-redirect.min.js 到指定文件夹。

  • ./firebase.json 被修改时
  • ./tool/host-redirect 工具相关被修改时

演示链接

@AmosHuKe AmosHuKe requested a review from a team as a code owner May 24, 2024 08:43
Copy link

github-actions bot commented May 24, 2024

👍 感谢你对 Flutter / Dart 文档本地化做出的贡献!

查看该 PR 的预览 URL (已更新至 commit: 38a44b1):

https://flutter-cn-docs-prod--pr1455-host-redirect-pp6fphjn.web.app

查看本 PR 贡献的链接预览:

https://flutter-cn-docs-prod--pr1455-host-redirect-pp6fphjn.web.app/docs/content/404.html
https://flutter-cn-docs-prod--pr1455-host-redirect-pp6fphjn.web.app/tool/host-redirect/README.html

(页面失效时间 2024/6/7 17:34:28 (北京时间))

本工具 修改自 部署至 🔥 Firebase Hosting

Sign: 4be6fc4fb8f048b3225659bec78d08e623eb7688

@AlexV525
Copy link
Member

天才

@chenglu
Copy link
Member

chenglu commented May 26, 2024

image

@chenglu
Copy link
Member

chenglu commented May 26, 2024

这相当于是在前端用 js 的方式跳转了对吧?@AmosHuKe

@AmosHuKe
Copy link
Member Author

@chenglu 是的,临时这样处理下,看起来还可以。

@AmosHuKe
Copy link
Member Author

AmosHuKe commented May 26, 2024

@chenglu 在没有更优雅的方式前(也许和上游对齐?),也许会一直用这个方式了

Copy link
Member

@chenglu chenglu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@chenglu chenglu merged commit 14029a4 into main May 26, 2024
8 checks passed
@chenglu chenglu deleted the host-redirect branch May 26, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants