Fix public asset 404s on GitHub Pages - #23
Merged
Conversation
Root-absolute asset paths bound via :src="'/foo.jpg'" bypass Vite's --base rewriting, so browsers requested them from the domain root instead of the deployed sub-path. Resolve BASE_URL in a script setup block and prepend it in the binding instead.
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.
Summary
me.jpg,claude-code-react-questions.mp4, andagile-software-development.jpgwere referenced as root-absolute string literals (:src="'/me.jpg'"), which Vite never rewrites with the configured--base, so on GitHub Pages they 404'd against the domain root instead of the deployed sub-path (e.g./presentations/ai-tech-debt/fr/).<script setup>block exposingimport.meta.env.BASE_URLin each affected slide and prepend it in the binding, so the built asset URL correctly includes the deploy base path.Test plan
slidev buildwith production--baseflags forai-tech-debt,solid,ai-for-beginners, andopaque-types(fr/en where applicable) — all succeed/presentations/ai-tech-debt/fr/me.jpg,/presentations/solid/fr/agile-software-development.jpg