Skip to content

Commit

Permalink
Merge pull request #80 from rocky-linux/remove-vercel
Browse files Browse the repository at this point in the history
don't try and serve from vercel
  • Loading branch information
NeilHanlon authored Jan 21, 2025
2 parents 1ed0045 + 370d072 commit 037c721
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions compute-js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async function handleRequest(event) {
vercelOverride.surrogateKey = 'vercel';

// Check if the requested path has a locale slug (e.g., /fr/)
// TODO(neil): this should be generated from the config
const localeRegex = /\/(af|de|fr|es|id|it|ja|ko|zh|sv|tr|pl|pt|pt-BR|ru|uk)\//
const hasLocaleSlug = localeRegex.test(path);

Expand All @@ -47,14 +48,8 @@ async function handleRequest(event) {
if (hasLocaleSlug) {
debugLog("Attempting to serve localized page for " + path);
beresp = await staticContentServer.serveRequest(event.request, 'public, max-age=21600, stale-while-revalidate=600');
if (beresp == null || beresp.status > 400) {
// doLog("Failed to serve localized page. Attempting to serve page from Vercel");
beresp = await fetch(event.request, {backend: backendName, vercelOverride});
// doLog("[vercel] " +beresp.url+"|"+beresp.status);
if (beresp != null && beresp.status < 400) {
debugLog("Localized content fetched from Vercel");
return beresp;
}
if (beresp != null && beresp.status < 400) {
return beresp;
}
}

Expand All @@ -67,15 +62,6 @@ async function handleRequest(event) {
return beresp;
}


// If we **still** can't find the artifact, try to find it on docs.r.o for the user, I guess
beresp = await fetch(originalRequest, {backend: backendName, vercelOverride});

if (beresp != null && beresp.status < 400) {
debugLog("content fetched from vercel (fallback)");
return beresp;
}

// If neither translation nor English version is found, return a 404 response
return new Response('Not found', { status: 404 });
}

0 comments on commit 037c721

Please sign in to comment.