Giter VIP home page Giter VIP logo

Comments (12)

tonyxiao avatar tonyxiao commented on June 26, 2024 1

Hmm just tested the first request does seem to be captured - it's only later requests that are cached that seems to be not captured.

from proxyman.

NghiaTranUIT avatar NghiaTranUIT commented on June 26, 2024

@tonyxiao It's expected behavior because fetch from NodeJS doesn't respect the system HTTP Proxy.

To capture the fetch, you should use the Automatic Setup: https://docs.proxyman.io/automatic-setup/automatic-setup

It will open the pre-configured Terminal -> Start your NodeJS server here -> Proxyman will automatically capture all NodeJS request/response 👍

from proxyman.

tonyxiao avatar tonyxiao commented on June 26, 2024

I used the automatic set up and it still didn't work.

from proxyman.

tonyxiao avatar tonyxiao commented on June 26, 2024

That was in the title of the issue actually

from proxyman.

tonyxiao avatar tonyxiao commented on June 26, 2024

To be sure it works for if I just run a node script, the problem is when I try to run next.js it doesn't work

from proxyman.

NghiaTranUIT avatar NghiaTranUIT commented on June 26, 2024

Ah, it's a special case: from react server components in next.js

My initial is a fetch from NodeJS server. Let me see

from proxyman.

NghiaTranUIT avatar NghiaTranUIT commented on June 26, 2024

I guess it's because fetch from NextJS is a custom version, and it ignores all system Proxy.

You should manually add the Proxy to the fetch and trust the self-signed certificate. Here is the answer: https://stackoverflow.com/questions/72306101/make-a-request-in-native-fetch-with-proxy-in-nodejs-18


Proxyman can't capture it automatically because it's how NextJS works.

from proxyman.

tonyxiao avatar tonyxiao commented on June 26, 2024

I see. What is the underlying networking lib next js uses? And wouldn't proxyman hook into that?

Separately would you be able to create an example of how to use proxyman with next.js? Feels like it should be in the docs somewhere too.

from proxyman.

tonyxiao avatar tonyxiao commented on June 26, 2024

@NghiaTranUIT following up here. Would love to have an example that works with next.js and some better understanding why it doesn't work out of the box.

from proxyman.

NghiaTranUIT avatar NghiaTranUIT commented on June 26, 2024

Sure, I will do it this weekend 👍

from proxyman.

NghiaTranUIT avatar NghiaTranUIT commented on June 26, 2024

@tonyxiao turn out Proxyman can capture the fetch from Server Side Component as soon as you don't use the caching.

  1. Start the Pre-configure Terminal on Tools -> Setup -> Automatic Setup
  2. Use no-cache on fetch
export default async function MyPage() {
  const res = await fetch('https://httpbin.org/anything', { cache: 'no-cache' }) // no cache, or no request is sent to Proxyman
  return <div>My Page{res.text()}</div>
}
  1. Start your NextJS server on this terminal
  2. Done ✅

Screenshot 2024-06-01 at 1 29 50 PM

from proxyman.

tonyxiao avatar tonyxiao commented on June 26, 2024

Interesting , I will give that a try. Strange why is that tho, as my request should hit a cache miss as it runs the first time, which apparently is not the same as "no-cache"?

from proxyman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.