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

fix: Ensure polly's middleware goes before ember-cli's #36

Conversation

cibernox
Copy link
Contributor

This should allow polly to work nicely with ember-cli's when the
--proxy option is passed.

This should allow polly to work nicely with ember-cli's when the
`--proxy` option is passed.
@offirgolan offirgolan merged commit 43db361 into Netflix:master Jun 21, 2018
@cibernox
Copy link
Contributor Author

Closes #35

@cibernox cibernox deleted the bugfix/ensure-polly-runs-before-ember-cli-middleware branch June 21, 2018 18:27
@Turbo87
Copy link

Turbo87 commented Jun 23, 2018

FYI this doesn't work quite as expected. The --proxy option in Ember CLI is only used for ember serve, so it does work when visiting /tests, but not when using ember test. That means that requests to a relative URL like /api/foo will not be proxied in test mode. What I did instead is this:

server.any().on('request', req => {
  if (req.url.startsWith('/api')) {
    req.url = `https://skylines.aero${req.url}`;
  }
});

This solution seems to work quite well now. I'm assuming that this is/will be a common issue for people using Polly.js, so it might make sense to add it to the documentation somewhere.

@cibernox
Copy link
Contributor Author

Just to clarify, this dies works as intended as long as Polly recorded the events already.

@offirgolan
Copy link
Collaborator

offirgolan commented Jun 25, 2018

@Turbo87 would specifying your proxy via testem solve this issue?

// testem.js
{
  browser_args: { /* */ },
  proxies: {
    '/api': {
      target: 'https://skylines.aero'
    }
  }
}

@Turbo87
Copy link

Turbo87 commented Jun 25, 2018

possibly, I wasn't aware testem could do this 🙈

@offirgolan
Copy link
Collaborator

😄 lemme know if it works and I'll add some documentation around it!

@Turbo87
Copy link

Turbo87 commented Jun 25, 2018

indeed, this seems to work very well. thanks for the idea!

@cibernox
Copy link
Contributor Author

I've also used that config and it's great. I didn't know that trick either.

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

Successfully merging this pull request may close these issues.

3 participants