Closed delucis closed 1 year ago
astro
2.5.0
n/a
npm/pnpm
macOS / Stackblitz
Firefox
Routes injected using the injectRoute integration API do not get scripts injected via the injectScript API added to them.
injectRoute
injectScript
I’ve tested injectScript('page', '...') and injectScript('page-ssr', '...') and both are not loaded on injected routes.
injectScript('page', '...')
injectScript('page-ssr', '...')
The reproduction shows the same route (src/route.astro) loaded at / (via src/pages/index.astro) and at /injected (via the injectRoute API).
src/route.astro
/
src/pages/index.astro
/injected
At /:
alert()
At /injected neither of these work.
Uncovered this here when someone tried adding the Tailwind integration to Starlight: https://github.com/withastro/starlight/issues/88
https://stackblitz.com/edit/github-ssvscu?file=astro.config.mjs
I found what is causing this issue. I'm working on a solution.
What version of
astro
are you using?2.5.0
Are you using an SSR adapter? If so, which one?
n/a
What package manager are you using?
npm/pnpm
What operating system are you using?
macOS / Stackblitz
What browser are you using?
Firefox
Describe the Bug
Routes injected using the
injectRoute
integration API do not get scripts injected via theinjectScript
API added to them.I’ve tested
injectScript('page', '...')
andinjectScript('page-ssr', '...')
and both are not loaded on injected routes.The reproduction shows the same route (
src/route.astro
) loaded at/
(viasrc/pages/index.astro
) and at/injected
(via theinjectRoute
API).At
/
:injectScript('page-ssr', '...')
to inject them)alert()
injected into the page also pops up.At
/injected
neither of these work.Uncovered this here when someone tried adding the Tailwind integration to Starlight: https://github.com/withastro/starlight/issues/88
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ssvscu?file=astro.config.mjs
Participation