bs-community / yggdrasil-api

Please refer to https://github.com/bs-community/blessing-skin-plugins .
MIT License
60 stars 7 forks source link

[feature request] 在 API 中添加跨域响应头 #31

Closed SerinaNya closed 4 years ago

SerinaNya commented 4 years ago

目前的 Yggdrasil API 没有跨域响应头,导致前端请求时报 Network Error

希望 Yggdrasil API 在返回数据时添加上跨域头 Access-Control-Allow-Origin: *,以达到在前端直接请求 API 的目的

g-plane commented 4 years ago

这些 API 并不是给前端用的。

SerinaNya commented 4 years ago

但是没说不可以给前端用

g-plane commented 4 years ago

是没有说不可以,但这个特性是「不必要」的,加了也没带来多大的好处。

SerinaNya commented 4 years ago

会有什么坏处?

g-plane commented 4 years ago

没带来多大的好处 != 有坏处

SerinaNya commented 4 years ago

既然这样,那就加呗。 我就是你这个意思

g-plane commented 4 years ago

我是说,我不觉得有加的必要性。

tnqzh123 commented 4 years ago

Mojang 也没有在官方的 Yggdrasil API 加 Access-Control-Allow-Access

感觉这个更应该由皮肤站来做,有需要的皮肤站自己加上。

SerinaNya commented 4 years ago

那就当成兼容前端查询吧,CSL 的 API 不就有跨域头么

g-plane commented 4 years ago

并没有。

SerinaNya commented 4 years ago

宁好,有 image

g-plane commented 4 years ago

您找演示站试试。

SerinaNya commented 4 years ago

您找演示站试试。

那个的确没有,但是你也知道,演示站过时了

ShirasawaSama commented 4 years ago

image 有是有, 但不是直接使用 * 的吧

g-plane commented 4 years ago

这与演示站过时与否没有关系,因为这部分代码基本没改变过,你自己搭建一个皮肤站就知道。

SerinaNya commented 4 years ago

:thinking: 我认为,加上这个头也不会有什么负面影响,反而能给一些(即使不多)开发者带来好处,何乐而不为?

tnqzh123 commented 4 years ago

image

LittleSkin 也没有。

感觉这个更应该由皮肤站来做,有需要的皮肤站自己加上。

g-plane commented 4 years ago

解决这个问题的更好方法是自己搭建 API 代理。

加上这个头也不会有什么负面影响

这意味这个 API 可以被跨站请求,不能保证没有负面影响。

SerinaNya commented 4 years ago

image

LittleSkin 也没有。

感觉这个更应该由皮肤站来做,有需要的皮肤站自己加上。

https://mcskin.littleservice.cn/Little_Qiu.json

SerinaNya commented 4 years ago

解决这个问题的更好方法是自己搭建 API 代理。

加上这个头也不会有什么负面影响

这意味这个 API 可以被跨站请求,不能保证没有负面影响。

可按照目前的认知来看,的确没有任何威胁

g-plane commented 4 years ago

解决这个问题的更好方法是自己搭建 API 代理。

SerinaNya commented 4 years ago

解决这个问题的更好方法是自己搭建 API 代理。

牺牲了速度,加大了成本。

g-plane commented 4 years ago

那您自行 fork 这个插件吧。(反正是开源的)

g-plane commented 4 years ago

其实也不需要 fork,自己写个插件,然后注册一个中间件并在中间件里修改头部同样是一个可行的办法。

SerinaNya commented 4 years ago

我去琢磨琢磨 :thinking:

tnqzh123 commented 4 years ago

@jinzhijie

https://mcskin.littleservice.cn/Little_Qiu.json

image

一样的。我没有故意加减 Access-Control-Allow-Origin。你也可以直接翻阅 BS 对应部分的代码。

SerinaNya commented 4 years ago

一样的。我没有故意加减 Access-Control-Allow-Origin。你也可以直接翻阅 BS 对应部分的代码。

image

:thinking: @tnqzh123

accept-ranges: bytes
access-control-allow-origin: *
cache-control: max-age=600
content-length: 220
content-type: application/json
date: Fri, 03 Apr 2020 02:32:21 GMT
etag: "5dd619f2-dc"
expires: Fri, 03 Apr 2020 02:42:21 GMT
last-modified: Thu, 21 Nov 2019 05:00:34 GMT
server: NWS_SP
status: 200
x-cache-lookup: Hit From Upstream
x-cache-lookup: Hit From Disktank3
x-daa-tunnel: hop_count=2
x-nws-log-uuid: 97c4779e-bd32-4ba2-a97c-0e8fde3e4ce4
x-nws-uuid-verify: 48c0ca4799af7b46a238ac70f15b855e
g-plane commented 4 years ago

有关 LittleSkin 的问题请私下交流,在这里讨论会导致很多人收到通知的。

SerinaNya commented 4 years ago

好的  

Xiao_Jin jinzhijie0916@qq.com

 

------------------ 原始邮件 ------------------ 发件人: "Pig Fang"<notifications@github.com>; 发送时间: 2020年4月3日(星期五) 上午10:44 收件人: "bs-community/yggdrasil-api"<yggdrasil-api@noreply.github.com>; 抄送: "Xiao_Jin"<742905606@qq.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [bs-community/yggdrasil-api] [feature request] 在 API 中添加跨域响应头 (#31)

有关 LittleSkin 的问题请私下交流,在这里讨论会导致很多人收到通知的。

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.