-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Handle absolute Vite base URL #9700
Conversation
🦋 Changeset detectedLatest commit: aaecd6c The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/remix-dev/vite/plugin.ts
Outdated
url: new URL( | ||
VirtualModule.url(browserManifestId), | ||
ctx.remixConfig.publicPath | ||
).href, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think ctx.remixConfig.publicPath
is guaranteed to be an absolute URL here, is it? If it's not, this will throw an exception:
> node
Welcome to Node.js v20.12.2.
Type ".help" for more information.
> new URL("file.txt", "/public")
Uncaught TypeError: Invalid URL
at new URL (node:internal/url:796:36) {
code: 'ERR_INVALID_URL',
input: 'file.txt',
base: '/public'
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I've updated the PR to use a function implemented the same way as the way axios combines urls
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
I think @pcattori and/or @markdalgleish should review this since they're more familiar with the vite plugin internals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some tests, but otherwise this looks great to me. Thanks for the PR!
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Currently if you set the
base
property invite.config.ts
to an full url (iehttp://localhost:5173/
), when runningvite:dev
the modulepreload link tags remove the second slash(/
) inhttp://local...
.Current behaviour:
Expected behaviour:
This is not the case when first running
vite:build
then serving the output withremix-serve ./build/server/index.js
, then it behaves as expected.I also checked the classic remix compiler, it also behaves as expected.
Testing Strategy:
I'm a bit unsure if all of the places should be changed, however since they all are based on the same path I think this should be correct. And in the limited testing I did there where no issues.