feat(apps): add Fillcode website HelmRelease
这个提交包含在:
@@ -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
|
||||
@@ -3,6 +3,7 @@ kind: Kustomization
|
||||
resources:
|
||||
- certificate-fillcode-com.yaml
|
||||
- certificate-sinceai-com.yaml
|
||||
- helmrelease-fillcode-website.yaml
|
||||
- helmrelease-halo.yaml
|
||||
- ingress-fillcode.yaml
|
||||
- ingress-halo-www.yaml
|
||||
|
||||
@@ -392,18 +392,23 @@ data:
|
||||
// 拦截网络请求
|
||||
self.addEventListener('fetch', e => {
|
||||
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方法,直接返回
|
||||
if (e.request.method !== 'GET') return
|
||||
|
||||
// 如果请求的域名不是当前页面的域名
|
||||
if (url.origin !== self.location.origin) return
|
||||
// 只处理同源资源和缺少当前站点子路径的CDN资源
|
||||
if (url.origin !== self.location.origin && !missingCdnPrefix) return
|
||||
|
||||
// 过滤__static路径下的请求
|
||||
if (url.pathname.startsWith('/__static/')) return
|
||||
|
||||
// 如果请求的路径不匹配静态资源正则表达式,直接返回
|
||||
if (!config.staticRegex.test(url.pathname)) return
|
||||
// 同源请求仍按静态资源规则过滤;CDN缺前缀请求直接修复
|
||||
if (!missingCdnPrefix && !config.staticRegex.test(url.pathname)) return
|
||||
|
||||
// 判断是否是强制需要同源请求
|
||||
const requiresSameOrigin = ['worker', 'sharedworker', 'serviceworker'].includes(e.request.destination)
|
||||
@@ -412,15 +417,11 @@ data:
|
||||
if (requiresSameOrigin) return
|
||||
|
||||
// 开始处理静态资源请求
|
||||
e.respondWith(handleStaticResource(e.request, url))
|
||||
e.respondWith(handleStaticResource(e.request, url, cdnPath))
|
||||
})
|
||||
|
||||
// 处理静态资源请求
|
||||
async function handleStaticResource(request, url) {
|
||||
// 生成CDN子路径
|
||||
const hostname = self.location.hostname
|
||||
const cdnPath = hostname.replace(/\./g, '-')
|
||||
|
||||
async function handleStaticResource(request, url, cdnPath) {
|
||||
const targetUrl = config.cdnUrl + cdnPath + url.pathname + url.search
|
||||
|
||||
if (config.debug) console.log('PWA-CDN:', url.href, '->', targetUrl)
|
||||
|
||||
在新议题中引用
屏蔽一个用户