-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Server.open can not be opened with default Network url #14921
Comments
You can pass a string to |
how to do that? I could not find any api in 'https://github.com/sindresorhus/open' to satisfy. |
It's in the Vite docs: https://vitejs.dev/config/server-options.html#server-open server: {
open: 'http://10.23.44.14:8080/'
} |
I guess thinking about it, you might not want the network url to not be hardcoded. You can try to resolve the |
I can't do this cause its a public project and someone else's ip must not be 10.23.44.14. |
I'll re-open for now if anyone has ideas to supporting this. We usually avoid adding new options unless if there's a large usecase. I'm thinking maybe we can flip this part vite/packages/vite/src/node/server/index.ts Lines 484 to 487 in 2687dbb
so that network URLs are checked first before the local URLs, and that might be good enough, but it's a breaking change. |
I think its a good idea to raise the network's priority, just like |
BTW why does opening the remote URL with the browser work for you? I guess you are setting |
Cause 'localhost' is set as proxy in all the company's computers for a certain purpose. |
Based on Vite's vite/packages/vite/src/node/utils.ts Lines 998 to 1020 in 5684fcd
this seems possible to achieve in one liner though this might be still too ugly to have in vite config... export default defineConfig({
server: {
open: true,
host: Object.values((await import("os")).networkInterfaces()).flat().filter(e => String(e.family).includes("4") && !e.address.includes("127.0.0.1"))[0].address
},
}) |
Description
server: {
host: '0.0.0.0',
port: 8080,
open: true,
}
when i run-script 'pnpm run dev', get 'http://localhost:8080/' in my default browser but not 'http://10.23.44.14:8080/'
Suggested solution
provide additional Server param to support default network url like 'http://10.23.44.14:8080/' in my browser.
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: