Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用flyio发出的GET请求也会先发一个预检请求OPTIONS #134

Closed
Claiyre opened this issue Sep 26, 2018 · 3 comments
Closed

使用flyio发出的GET请求也会先发一个预检请求OPTIONS #134

Claiyre opened this issue Sep 26, 2018 · 3 comments

Comments

@Claiyre
Copy link

Claiyre commented Sep 26, 2018

version

"flyio": "^0.6.1",

code

fly.get('https://wanproxy.127.net/lbs', {
  version: '1.0',
  bucketname: 'vod0j9f7jwb'
})
.then(res => console.log('res', res))
.catch(err => console.log(err))

image

使用原生XMLHttpRequest发出同样的get请求便不会发OPTIONS
image

这个接口是第三方的,发预检请求便会出错,若直接是get请求则不会

@wendux
Copy link
Owner

wendux commented Sep 26, 2018

你fly中有没有设置自定义header? 跨域请求含有自定义header的话就会发起预检,即使是get请求。 你对比一下fly和原生的request header看看有什么区别。

:octocat: From gitme Android

@Claiyre
Copy link
Author

Claiyre commented Sep 28, 2018

@wendux
我没有自定义header,fly替我定义了Content-Type 😛

image

是否可以在 isGet 时也 delete headers.contentType呢?

BTW,你写的代码真好看

@wendux
Copy link
Owner

wendux commented Sep 30, 2018

嗯 get请求时content type没有意义 节后会删掉

:octocat: From gitme Android

@wendux wendux closed this as completed in f27b361 Oct 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants