Skip to content
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

Cannot serve application on host 127.0.0.1 with shared options #194

Closed
nicotu01 opened this issue Nov 26, 2024 · 7 comments · Fixed by #196
Closed

Cannot serve application on host 127.0.0.1 with shared options #194

nicotu01 opened this issue Nov 26, 2024 · 7 comments · Fixed by #196

Comments

@nicotu01
Copy link
Contributor

Step to reproduce :

  1. create a simple vue project with vite.
  2. configure vite server.host to 127.0.0.1
  3. configure federation and share vue
  4. serve the application and open http://127.0.0.1 : the application does not work

Here my vite config:

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { federation } from "@module-federation/vite";

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    federation({ name: "host", shared: ["vue"] }),
  ],
});

@gioboa
Copy link
Collaborator

gioboa commented Nov 26, 2024

Hi @nicotu01
Can you share your errors too? Thanks

@nicotu01
Copy link
Contributor Author

There's are NO error ;-).
Only a white page.

I find how to resolve :

Use the server host :

          const {init} = await import("//${viteConfig.server?.host || 'localhost'}:${viteConfig.server?.port}${viteConfig.base + options.filename}")
          const { host, port } = server.config.server;
          fetch(`http://${host}:${port}${devEntryPath}`).catch((e) => {});

@nicotu01
Copy link
Contributor Author

And perhaps exclude the case where host = 0.0.0.0

@gioboa
Copy link
Collaborator

gioboa commented Nov 26, 2024

Nice @nicotu01 May I ask you to create a PR for that?

@nicotu01
Copy link
Contributor Author

Yes, of course.
But I can't create branch. Do I need permissions ?

@gioboa
Copy link
Collaborator

gioboa commented Nov 26, 2024

Sending a Pull Request

  • Fork the repository into your own account.
  • Clone your forked repository.
  • In your forked repository, create a new branch: git checkout -b my-branch main.
  • Make your changes/fixes.
  • Run pnpm fmt to lint the code.
  • Push your branch to GitHub: git push origin my-branch
  • In GitHub, send a pull request to module-federation/vite

@nicotu01
Copy link
Contributor Author

Hi @gioboa
Here is the PR : #196

But Playwright tests are broken.
I'm not that it is due to my code. I've the same error on main branch.

How can we progress on the subject ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants