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

提供类似 Obsidian requestUrl 的方法 #8702

Closed
mdzz2048 opened this issue Jul 7, 2023 · 4 comments
Closed

提供类似 Obsidian requestUrl 的方法 #8702

mdzz2048 opened this issue Jul 7, 2023 · 4 comments

Comments

@mdzz2048
Copy link
Contributor

mdzz2048 commented Jul 7, 2023

In what scenarios do you need this feature?

微信读书 Cookie 需要在请求中携带旧 Cookie才能更新。

Obsidian 的插件 使用 requestUrl | Obsidian 插件开发文档 方法实现这个功能

类似 fetch() 方法,使用HTTP/HTTPS请求 URL, 没有任何跨域限制。

export function requestUrl(request: RequestUrlParam | string): RequestUrlResponsePromise;

思源能否提供类似的方法?

Describe the optimal solution

提供没有跨域限制

Describe the candidate solution

No response

Other information

No response

@mdzz2048 mdzz2048 changed the title 支持没有跨域限制的请求 提供类似 Obsidian requestUrl 的方法 Jul 7, 2023
@svtardust
Copy link

axios请求库或许可以解决?

@mdzz2048
Copy link
Contributor Author

mdzz2048 commented Jul 7, 2023

axios请求库或许可以解决?

可以提供一些示例吗?我尝试过直接在 header 加 Cookie 但是不行。会报错 Refused to set unsafe header "cookie"。似乎是因为XMLHttpRequest 不允许设置某些标头,包括 Cookie

import axios from "axios";

axios.get('https://weread.qq.com', {
    headers: {
        cookie: 'some cookie'
    }, 
    withCredentials: true, 
})

我还尝试过用 fetch 发送请求,但是 Cookie 会被过滤

fetch('https://weread.qq.com', {
        method: 'GET',
        headers: {'Cookie': 'some cookie'}, 
        redirect: 'follow', 
        credentials: 'include'
});

image

@88250
Copy link
Member

88250 commented Jul 10, 2023

先在 https://ld246.com/article/1688832379540 中讨论吧。

@88250 88250 closed this as completed Jul 10, 2023
@88250
Copy link
Member

88250 commented Jul 10, 2023

Ref #8724

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

3 participants