flutterdarthttpweb

Flutter Web Status request


I want to make a status query of my web server for my website which I program with Flutter, which is green when the server is reachable and red when not. With my current code I always get a "XMLHttpRequest" error.

server_api.dart

I have already tried it by simple pinging but have also come to no solution.


Solution

  • try these headers

    get headers => {
        'Accept': '*/*',
        'Content-Type': 'application/json',
        'Access-Control-Allow-Origin': '*'
      };