Skip to content

Commit ec7739a

Browse files
committed
fix(rsc): use proper base+origin for source map lookup
1 parent 0d3912b commit ec7739a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/plugin-rsc/src/react/browser.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ export function findSourceMapURL(
5454
filename: string,
5555
environmentName: string,
5656
): string | null {
57-
// TODO: respect config.server.origin and config.base?
58-
const url = new URL('/__vite_rsc_findSourceMapURL', window.location.origin)
57+
// Respect config.base by using import.meta.env.BASE_URL
58+
// TODO: Handle relative base path.
59+
const base = import.meta.env.BASE_URL.replace(/\/$/, '')
60+
// Respect asset origin (e.g. server.origin) by using import.meta.url
61+
const url = new URL(base + '/__vite_rsc_findSourceMapURL', import.meta.url)
5962
url.searchParams.set('filename', filename)
6063
url.searchParams.set('environmentName', environmentName)
6164
return url.toString()

0 commit comments

Comments
 (0)