Sunday, 30 September 2018

Change host dynamically with SuperAgent

I'm trying to write a test where SuperAgent calls multiple (sub)domains, where cookies should be shared between them. Therefore, I want to swtich the agent dynamically, ie I can't create a new agent because I want the agent to retain cookies throughout.

  agent = request.agent("https://example1.com")
  agent.get('/path')
  agent.changeHost("https://example2.com") // Fake. How to actually do this?
  agent.get('/path') // Now we are retrieving same path from a different host

(syntax based on agency.js example)

I've also tried absolute URLs, ie agent.get('https://example1.com/path'), but that apparently isn't supported (Uncaught TypeError: Cannot read property 'address' of undefined`).



from Change host dynamically with SuperAgent

No comments:

Post a Comment