Flutter Web状态请求

huangapple go评论83阅读模式
英文:

Flutter Web Status request

问题

我想要查询我的网站的 web 服务器状态,我用 Flutter 编程,当服务器可达时为绿色,不可达时为红色。使用我的当前代码,我总是得到一个 "XMLHttpRequest" 错误。

server_api.dart

我已经尝试过简单的 ping,但也没有找到解决方案。

英文:

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.

答案1

得分: 1

尝试使用以下标头:

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

try these headers

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

huangapple
  • 本文由 发表于 2023年6月29日 05:43:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76576891.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定