英文:
Flutter Web Status request
问题
我想要查询我的网站的 web 服务器状态,我用 Flutter 编程,当服务器可达时为绿色,不可达时为红色。使用我的当前代码,我总是得到一个 "XMLHttpRequest" 错误。
我已经尝试过简单的 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.
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': '*'
};
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论