-
Notifications
You must be signed in to change notification settings - Fork 119
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
HTTP(S) Proxy | Agent With OhMyFetch #161
Labels
documentation
Improvements or additions to documentation
Comments
It's works for me on node 16.X import HttpsProxyAgent from 'https-proxy-agent'
import { ofetch } from 'ofetch'
await ofetch('user',{
agent: new HttpsProxyAgent('http://127.0.0.1:7890')
}) |
Yes, this worked for me too. Thx. Suppose, devs should declare agent option in fetch options. |
PR welcome to the docs. |
server\api\test\google.get.ts import {HttpsProxyAgent} from "https-proxy-agent";
import {$fetch, ofetch} from "ofetch";
const agent = new HttpsProxyAgent('http://127.0.0.1:7890')
export default defineEventHandler(async (event) => {
// const res = await ofetch('https://www.google.com', {
// agent: agent
// })
const res = await $fetch('https://www.google.com', {
agent: agent
})
console.log(res);
return res
}) curl test request curl http://localhost:3000/api/test/google
{"url":"/api/test/google","statusCode":500,"statusMessage":"","message":"[GET] \"https://www.google.com\": <no response> fetch failed","stack":"<pre><span class=\"stack internal\">at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</span>\n<span class=\"stack internal\">at async $fetchRaw2 (/node_modules/ofetch/dist/shared/ofetch.00501375.mjs:228:14)</span>\n<span class=\"stack internal\">at async $fetch2 (/node_modules/ofetch/dist/shared/ofetch.00501375.mjs:261:15)</span>\n<span class=\"stack\">at <anonymous> (\\server\\api\\test\\google.get.ts:9:1)</span>\n<span class=\"stack internal\">at async Object.handler (/node_modules/h3/dist/index.mjs:1675:19)</span>\n<span class=\"stack internal\">at async Server.toNodeHandle (/node_modules/h3/dist/index.mjs:1885:7)</span></pre>"}
C:\Users\Administrator> I'm use 'Clash for windows', I have tested with java http proxy, and it work fine. but i dont know why it not work with ofetch or $fetch. "nuxt": "^3.8.2", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there.
Just a short question.
How we could use
ohmyfetch
with HTTP(S) Proxy | Agent?For example.
If we use
axios
, we could useoptions.httpsAgent
with httpsAgentIn
ohmyfetch
I didn't find any docs about proxy and/orhttpsAgent
The text was updated successfully, but these errors were encountered: