Anu*_*ule 8 cors dart flutter flutter-web
我正在开发一个应用程序,在该应用程序中我使用 package.json 发出“http”请求import 'package:http/http.dart' as http;。当我使用它时,此请求工作正常Android,iOS但在Fultter Web我遇到CORS Policy问题时。
代码
Future<Details> verification(String id) async {
final http.Response response = await http
.post(
'https://secure.iccrc-crcic.ca/search/do/lang/en',
headers: <String, String>{
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST,GET,DELETE,PUT,OPTIONS',
'Accept': '*/*'
},
body:
"form_fields=%20lang%3Den%26search_last_name%3D%26search_first_name%3D%26search_iccrc_number%3D$id%26search_membership_status%3D1%26search_company_name%3D%26search_agent%3D%26search_country%3D%26search_province%3D%26search_postal_code%3D%26search_city%3D%26search_street%3D&query=%20&letter=%20&start=%200",
)
.timeout(Duration(minutes: 1));
if (response.statusCode == 200) {
return verificationEmail(response.body);
} else {
throw Exception('Failed to create album.');
}
}
Run Code Online (Sandbox Code Playgroud)
错误
Access to XMLHttpRequest at 'https://secure.iccrc-crcic.ca/search/do/lang/en'
from origin 'https://immigration-101.web.app' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Run Code Online (Sandbox Code Playgroud)
我对发出请求的端点没有任何控制权,因此无法在端点中添加允许标头解决方案。
请帮帮我。
| 归档时间: |
|
| 查看次数: |
1605 次 |
| 最近记录: |