Skip to content
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

Prefetch integration doesn't prepend the src path with the config.base #5566

Closed
1 task
Tanguy-Magnaudet opened this issue Dec 9, 2022 · 5 comments · Fixed by #5572
Closed
1 task

Prefetch integration doesn't prepend the src path with the config.base #5566

Tanguy-Magnaudet opened this issue Dec 9, 2022 · 5 comments · Fixed by #5572
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@Tanguy-Magnaudet
Copy link

What version of astro are you using?

1.6.14 // prefect is 0.1.1

Are you using an SSR adapter? If so, which one?

Node

What package manager are you using?

pnpm

What operating system are you using?

linux

Describe the Bug

When you add a base in the astro.config.mjs, it is not used by the prefetch integration in SSR mode.

Here is a discord support ticket with more details : How can I prefix assets href in SSR ?

This is what I get with the base configured as 'dist/views' :

<link rel="stylesheet" href="/dist/views/assets/404.07d04bcf.css" />
<script type="module" src="/page.5a6f3db5.js"></script>

And this is what I expect :

<link rel="stylesheet" href="/dist/views/assets/404.07d04bcf.css" />
<script type="module" src="/dist/views/page.5a6f3db5.js"></script>

Link to Minimal Reproducible Example

https://codesandbox.io/p/sandbox/frosty-glitter-we1x6f?file=%2Fastro.config.mjs&selection=%5B%7B%22endColumn%22%3A41%2C%22endLineNumber%22%3A11%2C%22startColumn%22%3A41%2C%22startLineNumber%22%3A11%7D%5D&workspace=%257B%2522activeFileId%2522%253A%2522cl8vqm78z0002lthi55o15wef%2522%252C%2522openFiles%2522%253A%255B%2522%252Fpackage.json%2522%252C%2522%252Fastro.config.mjs%2522%255D%252C%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522gitSidebarPanel%2522%253A%2522COMMIT%2522%252C%2522spaces%2522%253A%257B%2522clbg8tv41000u3b6ggw4fddcz%2522%253A%257B%2522key%2522%253A%2522clbg8tv41000u3b6ggw4fddcz%2522%252C%2522name%2522%253A%2522Default%2522%252C%2522devtools%2522%253A%255B%257B%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A3000%252C%2522url%2522%253A%2522we1x6f-3000.preview.csb.app%2522%252C%2522key%2522%253A%2522clbg95eex029z3b6g8lfor6v7%2522%252C%2522isMinimized%2522%253Afalse%257D%252C%257B%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clbg8zzwd00427qhifn67898s%2522%252C%2522key%2522%253A%2522clbg8zzrv00vo3b6gc9ffqhq0%2522%252C%2522isMinimized%2522%253Afalse%257D%255D%257D%257D%252C%2522currentSpace%2522%253A%2522clbg8tv41000u3b6ggw4fddcz%2522%252C%2522spacesOrder%2522%253A%255B%2522clbg8tv41000u3b6ggw4fddcz%2522%255D%257D

Participation

  • I am willing to submit a pull request for this issue.
@Tanguy-Magnaudet Tanguy-Magnaudet changed the title Prefect integration doesn't prepend the src path with the config.base Prefetch integration doesn't prepend the src path with the config.base Dec 9, 2022
@matthewp matthewp self-assigned this Dec 9, 2022
@matthewp matthewp added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Dec 9, 2022
@matthewp
Copy link
Contributor

matthewp commented Dec 9, 2022

Thanks. I think this problem seems unrelated to prefetch, right?

@Tanguy-Magnaudet
Copy link
Author

I don't really know how astro works behind the scene but I only face the problem with that script tag with the page.5a6f3db5.js

Inside that file I found some error messages related to the Prefetch integration so I assumed it was related.
The base is correctly applied with every other files in the client folder generated by the build.

@matthewp
Copy link
Contributor

matthewp commented Dec 9, 2022

Oh, I think I understand now, page.5a6f3db5.js is added by the prefetch integration. That helps me track down the issue.

@wassfila
Copy link

wassfila commented Dec 9, 2022

@matthewp if this helps, I reproduced the issue and the funny thing is that the page.xxx.js was served on both base and non base when running node in standalone, but the script tag is lacking the base which make it not work when you need to deploy the script only on base and not on root.

@matthewp
Copy link
Contributor

matthewp commented Dec 9, 2022

I have a fix in #5572, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants