Skip to content

Commit 5384eda

Browse files
afuchereca-agent
andcommitted
fix(website): prefix astrochart.js path with BASE_URL
The bundle was hard-coded as '/astrochart.js' (root-relative) in ChartDemo.astro. With base: '/AstroChart' in astro.config.mjs the file is deployed at /AstroChart/astrochart.js, so the browser was requesting the wrong path and getting a 404. Pass import.meta.env.BASE_URL into the is:inline script via define:vars and prefix both the querySelector guard and the dynamic script.src with it. Astro guarantees BASE_URL ends with '/', so concatenating 'astrochart.js' produces the correct path. 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca <git@eca.dev>
1 parent f130b50 commit 5384eda

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

website/src/components/ChartDemo.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ const codeSnippet = getCodeSnippet()
7878
chartMode: mode,
7979
chartHeight: height,
8080
radixData: defaultRadixData,
81-
transitData: defaultTransitData
81+
transitData: defaultTransitData,
82+
baseUrl: import.meta.env.BASE_URL
8283
}}
8384
>
8485
;(function () {
@@ -112,7 +113,7 @@ const codeSnippet = getCodeSnippet()
112113
if (window.astrochart) {
113114
// Library already loaded — init immediately
114115
initChart()
115-
} else if (document.querySelector('script[src="/astrochart.js"]')) {
116+
} else if (document.querySelector('script[src="' + baseUrl + 'astrochart.js"]')) {
116117
// Another instance is already loading the bundle — queue up
117118
window.__astrochartQueue = window.__astrochartQueue || []
118119
window.__astrochartQueue.push(initChart)
@@ -122,7 +123,7 @@ const codeSnippet = getCodeSnippet()
122123
window.__astrochartQueue.push(initChart)
123124

124125
var script = document.createElement('script')
125-
script.src = '/astrochart.js'
126+
script.src = baseUrl + 'astrochart.js'
126127
script.onload = function () {
127128
var queue = window.__astrochartQueue || []
128129
window.__astrochartQueue = []

0 commit comments

Comments
 (0)