feat(apps): add Fillcode website HelmRelease

这个提交包含在:
2026-08-24 15:57:41 +08:00 未验证
父节点 556d711ec8
当前提交 c2ca34e67e
修改 3 个文件,包含 37 行新增10 行删除
@@ -0,0 +1,25 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: fillcode-website
namespace: apps
spec:
interval: 30m
timeout: 15m
chart:
spec:
chart: website
version: 0.0.1
sourceRef:
kind: HelmRepository
name: devcm-repo
namespace: infra-gitops
interval: 12h
values:
ingress:
main:
enabled: true
tls:
- hosts:
- fillcode.com
secretName: fillcode-com-crt
+1
查看文件
@@ -3,6 +3,7 @@ kind: Kustomization
resources: resources:
- certificate-fillcode-com.yaml - certificate-fillcode-com.yaml
- certificate-sinceai-com.yaml - certificate-sinceai-com.yaml
- helmrelease-fillcode-website.yaml
- helmrelease-halo.yaml - helmrelease-halo.yaml
- ingress-fillcode.yaml - ingress-fillcode.yaml
- ingress-halo-www.yaml - ingress-halo-www.yaml
@@ -392,18 +392,23 @@ data:
// 拦截网络请求 // 拦截网络请求
self.addEventListener('fetch', e => { self.addEventListener('fetch', e => {
const url = new URL(e.request.url) const url = new URL(e.request.url)
const cdnPath = self.location.hostname.replace(/\./g, '-')
const cdnPrefix = `/${cdnPath}`
const missingCdnPrefix = url.origin === new URL(config.cdnUrl).origin
&& url.pathname !== cdnPrefix
&& !url.pathname.startsWith(`${cdnPrefix}/`)
// 如果请求不是GET方法,直接返回 // 如果请求不是GET方法,直接返回
if (e.request.method !== 'GET') return if (e.request.method !== 'GET') return
// 如果请求的域名不是当前页面的域名 // 只处理同源资源和缺少当前站点子路径的CDN资源
if (url.origin !== self.location.origin) return if (url.origin !== self.location.origin && !missingCdnPrefix) return
// 过滤__static路径下的请求 // 过滤__static路径下的请求
if (url.pathname.startsWith('/__static/')) return if (url.pathname.startsWith('/__static/')) return
// 如果请求的路径不匹配静态资源正则表达式,直接返回 // 同源请求仍按静态资源规则过滤;CDN缺前缀请求直接修复
if (!config.staticRegex.test(url.pathname)) return if (!missingCdnPrefix && !config.staticRegex.test(url.pathname)) return
// 判断是否是强制需要同源请求 // 判断是否是强制需要同源请求
const requiresSameOrigin = ['worker', 'sharedworker', 'serviceworker'].includes(e.request.destination) const requiresSameOrigin = ['worker', 'sharedworker', 'serviceworker'].includes(e.request.destination)
@@ -412,15 +417,11 @@ data:
if (requiresSameOrigin) return if (requiresSameOrigin) return
// 开始处理静态资源请求 // 开始处理静态资源请求
e.respondWith(handleStaticResource(e.request, url)) e.respondWith(handleStaticResource(e.request, url, cdnPath))
}) })
// 处理静态资源请求 // 处理静态资源请求
async function handleStaticResource(request, url) { async function handleStaticResource(request, url, cdnPath) {
// 生成CDN子路径
const hostname = self.location.hostname
const cdnPath = hostname.replace(/\./g, '-')
const targetUrl = config.cdnUrl + cdnPath + url.pathname + url.search const targetUrl = config.cdnUrl + cdnPath + url.pathname + url.search
if (config.debug) console.log('PWA-CDN:', url.href, '->', targetUrl) if (config.debug) console.log('PWA-CDN:', url.href, '->', targetUrl)