Skip to content

Commit

Permalink
fix: vite.base may be passed full URL but not consider (#186)
Browse files Browse the repository at this point in the history
Vite config options `base` can use full URL but node:path join throws AssertionError.

See https://vite.dev/config/shared-options

This changes consider URL and extract pathname.
Since @fastify/[email protected] occurs.

relates to #153

Signed-off-by: Kimiaki Kuno <[email protected]>
  • Loading branch information
knokmki612 authored Nov 8, 2024
1 parent 7af1646 commit 0299f27
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/fastify-vite/mode/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ async function setup(config) {
}
await scope.register(FastifyStatic, {
root,
prefix: join(vite.base || '/', assetsDir).replace(/\\/g, '/'),
prefix: join(
URL.canParse(vite.base)
? new URL(vite.base).pathname
: vite.base || '/',
assetsDir
).replace(/\\/g, '/'),
})
})

Expand Down

0 comments on commit 0299f27

Please sign in to comment.