Redirect to BaseURL in CI deployments#87
Conversation
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
|
Regarding this using the |
136c50c to
a3bf763
Compare
|
sigh |
|
i suppose that is one way to do a rebase 😭 |
There was a problem hiding this comment.
im sorta scared about feeding unfiltered and unsanitized stuff into the regex engine. this entire file is a bit scary and gives me some unease. dynamic redirects like this can end up being an easy attack vector
There was a problem hiding this comment.
PR Overview
This PR fixes an issue where links from the GitHub Deployments bot are pointing to an incorrect URL during CI deployments by redirecting the URL to the correct BaseURL.
- Added a JavaScript redirect script that recalculates URLs based on a provided BaseURL.
- Updated hugo.yaml to include caching configuration for the new JavaScript assets.
Reviewed Changes
| File | Description |
|---|---|
| assets/js/redirect.js | New script to handle URL redirection in CI builds |
| hugo.yaml | Updated cachebusters configuration |
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| const newUrl = new URL(url.pathname.replace(baseUrl, ""), baseUrl); | ||
| window.location.href = newUrl.toString(); | ||
| } | ||
| })("@params"); |
There was a problem hiding this comment.
The self-invoking function is being passed the string "@params" instead of an object with a baseUrl property, which may lead to a runtime error. Ensure that a valid object is passed to correctly provide the baseUrl.
| })("@params"); | |
| })({ baseUrl: "https://example.com" }); |
Currently, if you go on any PR and click on a link from the GitHub Deployments bot, it'll take you to the wrong URL. Normally it'd work fine, but because Hugo depends on
BaseURLbeing correct, it breaks. This PR fixes that issue by automatically redirecting toBaseURLif you access the site from another domain, only when building in CI.