-
Notifications
You must be signed in to change notification settings - Fork 174
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
Unable to configure CORS to access MUD v2 DApp on different host #860
Comments
after a bit of investigating, it seems to be because this Vite.js issue hasn't actually been resolve, or i'm not configuring it correctly vitejs/vite#652
to instead be
|
UPDATE: This may not have worked as I thought.... |
this is the codebase where I get the error https://github.com/ltfschoen/MUDTest |
this seems like a cors issue with anvil, not vite (anvil is running on port |
Thanks for your prompt response! I figured out a solution and posted it here vitejs/vite#13240 (comment). Basically the Anvil documentation mentions Docker configuration here, but I didn't appreciate it's significance https://book.getfoundry.sh/reference/anvil/#usage-within-docker. It says you can "use the ANVIL_IP_ADDR environment variable to set the host's IP. ANVIL_IP_ADDR=0.0.0.0 is equivalent to providing the --host option" "In order to run anvil as a service ... with the Docker container". So instead of just running Perhaps we could mention in the MUD v2 documentation that the use of setting Otherwise I'm happy for this issue to be closed. |
I'm running a MUD v2 DApp in a Docker container, and exposing ports 8545 and 3000 so I can access it on the host machine in my browser at http://localhost:3000 (as mentioned here #859)
But since I'm accessing it from a different origin I need to allow CORS headers.
Initially it gave me the following CORS error:
Then I found the relevant Vite.js docs https://vitejs.dev/config/server-options.html#server-cors and modified packages/client/vite.config.ts in the example DApp adding the
cors
property, so it's contents became:Then I stopped the server, and even rebuild it with
pnpm initialize
, and then started it again withpnpm run dev
, but I still get the same CORS errorsEven if I change it to
origin: "*",
i still get the same errorthe
mud devnode
is definitely running on the Docker container and generating blocks, and says in the logsListening on 127.0.0.1:8545
The text was updated successfully, but these errors were encountered: