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

Enable Ajax calls to external resource #228

Closed
mydea opened this issue Aug 5, 2015 · 10 comments
Closed

Enable Ajax calls to external resource #228

mydea opened this issue Aug 5, 2015 · 10 comments

Comments

@mydea
Copy link

mydea commented Aug 5, 2015

Hi,

I'm using ember-cli-mirage in my app and it works fine so far. However, I need to access an external service (https://www.telize.com/geoip) and fetch data from it. I do not need ember-cli-mirage/pretender to handle this, just ignore it. I tried

this.pretender.get('https://www.telize.com/geoip', this.pretender.passthrough);

But I nevertheless get "Error: Pretender will not respond to requests for URLs.". Am I missing something or is it simply impossible to access external URLs while using ember-cli-mirage?

@samselikoff
Copy link
Collaborator

Pretender actually was the reason for this until recently, the relevant PR just got merged. Try updating your Pretender.js to version 0.9.0 in your bower.json and see if that works

@mydea
Copy link
Author

mydea commented Aug 6, 2015

I tried this, but after updating to Pretender 0.9.0 my page doesn't load anymore.I get no errors or warnings, just an empty page. After downgrading to 0.6.0, it works again. (Note that it stops working whenever I use any Pretender version > 0.6.0)

@samselikoff
Copy link
Collaborator

Ok - I'll have to take a closer look when I have some time. Did the Pretender API change?

@mydea
Copy link
Author

mydea commented Aug 7, 2015

Seems like I found the issue - apparently, Passthrough-Requests only work with jQuery 2.x:
pretenderjs/pretender#85

It works now after upgrading to jquery 2.1.4 and Pretender 0.9.0.

@kottenator
Copy link

I have the same problem. Pretender 0.7.0 is "catching" what it shouldn't catch and after I update it to 0.9.0 - blank screen, nothing works... And I can't switch to jQuery 2.x :-(

@kottenator
Copy link

@mydea - I'm not sure if jQuery 1.x causes the problem.

I've tried to reproduce the bug with pure Pretender 0.9.0 and it works with jQuery 1.11.3 - here is my demo (in case if it's down - here is its source)

So Pretender 0.9.0 works fine with jQuery 1.11.3 and doesn't intercept JSONP to the same domain. But when I do this in my Ember app, it gives the blank screen and all is broken. Maybe it's problem with ember-cli-mirage?

@jamesdixon
Copy link
Contributor

This doesn't appear to be a jquery or pretender issue. I'm pretty sure I have a fix and will be submitting a PR as soon as I test it. Stay tuned.

jamesdixon added a commit to jamesdixon/ember-cli-mirage that referenced this issue Aug 10, 2015
@blimmer
Copy link
Contributor

blimmer commented Aug 15, 2015

@jamesdixon I see that you've tagged this issue in a commit.

Can we get an update on what (if anything) needs to be done here?

@jamesdixon
Copy link
Contributor

@blimmer see this PR. In a nutshell, I need someone to re-run the Travis CI build (didn't see a way to do it myself) as it failed, but didn't appear to fail because of my changes. All tests passed on my end.

jamesdixon added a commit to jamesdixon/ember-cli-mirage that referenced this issue Aug 17, 2015
jamesdixon added a commit to jamesdixon/ember-cli-mirage that referenced this issue Aug 17, 2015
* 'master' of https://github.com/jamesdixon/ember-cli-mirage:
  added support for fqdn's directly in the configuration without using urlPrefix
  adds support for urlPrefix to allow requests to external resources; fixes miragejs#228
jamesdixon added a commit to jamesdixon/ember-cli-mirage that referenced this issue Aug 17, 2015
@jrdn91
Copy link

jrdn91 commented Nov 30, 2015

I'm having the same issue here in this issue
#404
Is there something that I need to do related to this discussion/PR to get external resources to passthrough properly?

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

6 participants