-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Base path not working like the docs said #2140
Comments
I had this issue, and did this in the build script as a workaround, the problem is setting basepath doesn't affect where Astro puts the build assets: So make your base path directory in dist/ then copy/move the files from dist to the correct place.
Then have your hrefs and src's point at /ok/theAsset.png/js etc I spoke to Nate on their discord about this he was enquiring on if this was intended behavior. |
Thanks for your suggestion 🙏. But seem we need official support for everyone can use this 😁. |
this feels like a painful issue, every Astro user has a different adhoc solution, here's what I ended up doing, a custom config file if(process.env.MODE == "MIDDLEWARE"){
config.base = ""
} because if I try to import the config in astro.config.mjs, then I get a real dev server crash, mystery, closed it only because it's vite, not Astro, but issue still valid posted details here withastro/astro#5517 |
Yeah I think there needs be a cross-platform solution to how basePath is applied - but this open source so we can all find a solution and contribute rather than relying on the core team @wassfila my company are happy to work on a proposal for this in terms of functionality but the trouble we'd need to deal with the various adaptors I think.(vercel, upcoming AWS, netfly etc) so any core team input on what the preferred direction is would help before we do the work. |
That's true @marcfielding1 , especially for improvements that break compatibility. For base and many others, Astro inherites Vites problems, see https://vitejs.dev/config/shared-options.html#base |
basePath seems wonky at the moment but without being involved in internal astro dev conversation I can't criticise really, so yeah lets see what the team come back with - it definitely needs work, just in line with the goals I guess. |
LOL, seems not to work for me in my case 😆. Bcs we have a web with the old path Currently, I use the scripts to replace the path in |
Moving to the docs repo since this is a docs issue. Using the base in development is intended behavior. |
I think this is related to the rabbit hole of PRs that started here: #1643 that I am trying to pin down! I suspect we actually have proper docs that were blocked by some unexpected behaviour. I think we're unblocked, and I'm trying to confirm whether we can now re-merge a previous docs fix that we intended to have! 😅 |
And, looks like I should be able to close this! Although this previous PR to our configuration reference was merged, it was reverted to fix a bug with the intention we'd add it back after bug fix. Bug is fixed, and we'll be re-introducing this into docs: https://github.com/withastro/astro/pull/4954/files If you notice any problems, feel free to reopen! |
Followup: withastro/astro#5693 has been made to address this. Comments can be made there! |
What version of
astro
are you using?latest
Are you using an SSR adapter? If so, which one?
NodeJs 18 LTS + SSR nodejs standalone
What package manager are you using?
yarn 3
What operating system are you using?
Mac
Describe the Bug
https://docs.astro.build/en/reference/configuration-reference/#base
The docs said it only affects production. But seem in development, this still have effect.
When I config
astro.config.js
like thisIn dev mode, it will throw a warning like this
And the screen shows like this
In my mind, I think this base path is like the concept of NextJs. But seem not correct like they do.
--- With NextJs concept
When I config
basePath
to/ok
--> In production mode, at least this will auto append/ok
to the href withnext/link
. And the assets must be appended with base pathok/
.But seem Astro not auto append href 🤔.
Link to Minimal Reproducible Example
Stackblitz did not work correctly with the base path. So your team needs to pull this source code 😆.
https://github.com/harrytran998/rep-astro-base-path
(Here is the version of stackblitz to check https://stackblitz.com/edit/github-ncwvvs?file=astro.config.mjs)
Participation
The text was updated successfully, but these errors were encountered: