Fix for root apps#2
Open
tim-webflow wants to merge 14 commits into
Open
Conversation
b305093 to
7ee5aa6
Compare
7ee5aa6 to
506dfac
Compare
rjbeers
reviewed
Apr 13, 2026
| build: { | ||
| assetsPrefix: "/app", | ||
| }, | ||
| base, |
There was a problem hiding this comment.
During the webflow cloud build process, we will overwrite base to be the value of your mount path found in the dashboard, so setting the base here doesn't really do anything.
| try { | ||
| setLoading(true); | ||
| const response = await fetch(`${import.meta.env.BASE_URL}/api/list-assets`); | ||
| const response = await fetch(`${assetsPrefix}api/list-assets`); |
There was a problem hiding this comment.
I think you might want to use Astro's url constructor to generate the right urls instead of trying to build it yourself with BASE_URL and managing slashes.
133c566 to
491fb36
Compare
Add favicon SVG file
…ew-env Update for root apps new env
Add favicon SVG file
Reads the deployment's mount path from the runtime env (injected by the Cosmic builder) and threads it through to the client so fetch() calls resolve to the same worker that served the page. Previously `/app` pages were hitting `/`'s worker (and its R2 bucket) because `import.meta.env.BASE_URL` is baked in at build time and always defaulted to `/`. - Add `src/utils/mountPath.ts` helper that normalizes the value to start and end with `/`. - `Layout.astro`: use it for the favicon `<link>`. - `index.astro`: pass `mountPath` as a prop to `<FileUploader>`. - `files.astro`: expose via `data-mount-path` and read in the script. - `FileUploader.tsx`: accept `mountPath` prop, compute `apiBase` with a `typeof window` guard so SSR doesn't crash, and use it for all four fetch calls. Co-authored-by: Cursor <cursoragent@cursor.com>
…-for-root-apps-new-env Route API calls to per-deployment worker via COSMIC_MOUNT_PATH
Fix: route API calls to the deployment's own worker (sub-path apps)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As it stands this app does not work when published to the root path. THis update makes it work whether it's published to a site (which requires a subpath) or as an independent Webflow Cloud project where it can be at a subpath like
/appor the root path.This works for me testing in my workspace but please check to make sure I'm using Astro and the environment variables that Webflow Cloud uses correctly.