skip to Main Content

I have a basic flutter website that works fine in localhost when doing flutter run -d chrome, but when I was ready to publish it, with the command flutter build web, it shows a blank page and throw some generic errors by console.

Console errors on developer options

Checking other answers such as change the href on the index.html page aren’t working.
Running flutter doctor -v is showing this error, which I can’t find anything useful about, but the website cocoapods that is referencing is not available

[!] HTTP Host Availability X HTTP host "https://cocoapods.org/" is not reachable. Reason: Failed to connect to host in 10 seconds

2

Answers


  1. Chosen as BEST ANSWER

    Thank you for your answer Adedokun,

    So, turns out I'm still learning, and the index.html page is never going to work alone, according to the documentation here, you need to go to the folder root and launch a server by console, in this case I did with python -m http.server 8000, and navigated in a browser to localhost:8000, then go to build, then web. Also, in the /build/web index.html, needed to change the href="/" to href="./" so it could work finally, it appears that href="" works too. I hope this helps someone too.

    and about the Availability, it was just temporal, this morning the flutter doctor didn't show any error :)


  2. This has to deal with CORS error. one way of fixing this by using the HTML renderer.

    flutter build web --web-renderer html
    

    or try the solutions here. Link

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search