您好,我正在制作一个使用http框架并发送服务器以获取请求的应用。我正在使用Aqueduct进行后端服务,并且当我使用POSTMAN发送“获取请求”时可以使用,但是当我使用我的应用程序发送“获取请求”时,Aqueduct会在控制台上显示一条消息:
Loop Media
当我使用邮递员发送get请求时,一切都很好,服务器给出了响应:
[INFO] aqueduct: OPTIONS /workers 8ms 403 {user-agent : Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/IP_ADRESS Safari/537.36\nconnection : keep-alive\naccept : */*\naccept-language : en-US,en;q=0.9\nsec-fetch-mode : cors\naccept-encoding : gzip, deflate, br\norigin : http://localhost:58095\nhost : localhost:8888\nsec-fetch-site : same-site\naccess-control-request-headers : authorization,companymail,content-type\naccess-control-request-method : GET\nreferer : http://localhost:58095/\n}
我的邮递员标题:
[INFO] aqueduct: GET /workers 92ms 200
我的Flutter应用标题:
companyMail:deneme1234
Content-Type:application/json
Authorization:Basic ZGVuZW1lMTIzNDpkZW5lbWUxMjM0
我的Flutter应用收到请求:
final Map<String, String> headers = {"Content-Type": "application/json"};
String basicAuth = 'Basic ' + base64Encode(utf8.encode('$mail:$password'));
headers['authorization'] = basicAuth;
headers['companyMail'] = companyMail;
return headers
答案 0 :(得分:0)
最后,我找到了解决方案:)关于CorsPolicy。如果要发送带有请求的特殊标头,则必须检查服务器可接受的标头。在渡槽中,您可以像这样编辑允许的请求标头:
[HMR] Waiting for update signal from WDS...
backend.js:6 ../frontEnd/node_modules/process/browser.js
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\process\browser.js
Used by 2 module(s), i. e.
C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\react-error-overlay\lib\index.js
* C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\Users\User\Desktop\Image_Uploader\frontend\node_modules\process\browser.js
Used by 1 module(s), i. e.
C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\Users\User\Desktop\Image_Uploader\frontend\node_modules\axios\lib\defaults.js
r @ backend.js:6
printWarnings @ webpackHotDevClient.js:137
handleWarnings @ webpackHotDevClient.js:142
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:209
backend.js:6 ../frontEnd/node_modules/webpack/buildin/global.js
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\webpack\buildin\global.js
Used by 1 module(s), i. e.
C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\node-libs-browser\node_modules\punycode\punycode.js
* C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\Users\User\Desktop\Image_Uploader\frontend\node_modules\webpack\buildin\global.js
Used by 2 module(s), i. e.
C:\Users\User\Desktop\Image_Uploader\frontEnd\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\Users\User\Desktop\Image_Uploader\frontend\node_modules\gud\index.js
r @ backend.js:6
printWarnings @ webpackHotDevClient.js:137
handleWarnings @ webpackHotDevClient.js:142
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:209