@@ -41,19 +41,7 @@ const prodHandler = (app: FastifyInstance) => {
|
||||
|
||||
const upstreamEnv = req.requestContext.get("upstreamEnv")
|
||||
if (isInVercelReverseProxy || upstreamEnv === "prod") {
|
||||
// Add asset prefix
|
||||
// Map all link and script to /assets
|
||||
// <script type="module" crossorigin src="/assets/index-kQ31_hj7.js"></script>
|
||||
// <link rel="stylesheet" crossorigin href="/assets/index-BORNdGZP.css">
|
||||
const prefix = "/external-dist"
|
||||
const { document } = parseHTML(template)
|
||||
for (const script of document.querySelectorAll("script")) {
|
||||
script.src = `${prefix}${script.src}`
|
||||
}
|
||||
for (const link of document.querySelectorAll("link")) {
|
||||
link.href = `${prefix}${link.href}`
|
||||
}
|
||||
|
||||
const upstreamEnv = req.requestContext.get("upstreamEnv")
|
||||
|
||||
if (upstreamEnv) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "/((?!external-dist).*)",
|
||||
"source": "/((?!external-dist|dist-external).*)",
|
||||
"destination": "/api"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -18,6 +18,15 @@ export default () => {
|
||||
...viteRenderBaseConfig.define,
|
||||
ELECTRON: "false",
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
assetFileNames: "dist-external/[name]-[hash].[ext]",
|
||||
chunkFileNames: "dist-external/[name]-[hash].js",
|
||||
entryFileNames: "dist-external/[name]-[hash].js",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [react(), twMacro()],
|
||||
|
||||
server: {
|
||||
|
||||
+26
-1
@@ -21,7 +21,11 @@
|
||||
"destination": "https://follow-external-ssr.vercel.app/:path*"
|
||||
},
|
||||
{
|
||||
"source": "/((?!assets|vendor|locales/).*)",
|
||||
"source": "/dist-external/:path*",
|
||||
"destination": "https://follow-external-ssr.vercel.app/dist-external/:path*"
|
||||
},
|
||||
{
|
||||
"source": "/((?!assets|vendor|locales|dist-external/).*)",
|
||||
"destination": "/index.html"
|
||||
}
|
||||
],
|
||||
@@ -79,6 +83,27 @@
|
||||
"value": "max-age=604800"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"source": "/dist-external/(.*)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Cache-Control",
|
||||
"value": "public, max-age=604800, immutable"
|
||||
},
|
||||
{
|
||||
"key": "CDN-Cache-Control",
|
||||
"value": "max-age=604800"
|
||||
},
|
||||
{
|
||||
"key": "Vercel-CDN-Cache-Control",
|
||||
"value": "max-age=604800"
|
||||
},
|
||||
{
|
||||
"key": "Cloudflare-CDN-Cache-Control",
|
||||
"value": "max-age=604800"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user