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

Passthrough is not working at all #404

Closed
jrdn91 opened this issue Nov 24, 2015 · 20 comments
Closed

Passthrough is not working at all #404

jrdn91 opened this issue Nov 24, 2015 · 20 comments

Comments

@jrdn91
Copy link

jrdn91 commented Nov 24, 2015

I'm attempting to connect to pubnub in my app and when pubnub attempts to make a connection it always connects at a different url that looks something like this

http://ps5.pubnub.com/...

But that subdomain part before pubnub.com is always a different number.

I'm not sure how I can easily account for this url in a passthrough that has a variable part, but for the time being I've never seen the number go over 20, so I made 20 instances of a passthrough that captures the entire url that looks like this

this.passthrough('http://ps1.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps2.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps3.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps4.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps5.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps6.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps7.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps8.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps9.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps10.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps11.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps12.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps13.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps14.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps15.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps16.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps17.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps18.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps19.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');
  this.passthrough('http://ps20.pubnub.com/time/0?uuid=bidr-ember&pnsdk=PubNub-JS-Web%2F3.7.16');

But it still isn't working, each time I refresh and it hits a different number, I still get the error in the console that mirage says there was not a url found, but when I copy the url it's claiming it's trying to hit and search in the config file for it I find the exact url defined in one of the passthroughs, but it's not passing through to the pubnub server.

I'm using "ember-cli-mirage": "0.1.11", "pretender": "~0.10.1", and "jquery": "^2.1.4"

@jrdn91 jrdn91 changed the title Add a passthrough using a regular expression? Passthrough is not working at all Nov 30, 2015
@jrdn91
Copy link
Author

jrdn91 commented Nov 30, 2015

Still having issues with this, could really use an eye, it's blocking my project pretty bad

@samselikoff
Copy link
Collaborator

Hm, try dropping the query param part of the URL string?

@jrdn91
Copy link
Author

jrdn91 commented Nov 30, 2015

So just like this.passthrough('http://ps1.pubnub.com/time/0');? That doesn't seem to be working for any of them either

@samselikoff
Copy link
Collaborator

Is there any way you can reproduce this in a barebones ember app?

@jrdn91
Copy link
Author

jrdn91 commented Nov 30, 2015

I can attempt to do that

@ming-codes
Copy link

I'm having the same issue.

I can see the request go through, but the callback never fires.

@ming-codes
Copy link

I'm still investigating. If you want a sample app, you clone my repo and checkout the branch refactor/mirage.

  1. ember s
  2. localhost:4200
  3. Breakpoint on L168 in pretender.js
  4. Click Guides

The request is fired from routes/guides.js

@samselikoff
Copy link
Collaborator

the callback never fires

This sounds like a bug some were encountering while using passthrough with jquery < 2, what version of jquery are you on @ming-codes?

(Unfortunately, passthrough currently only works with jquery >= 2.x. There is a pretender issue for this).

@ming-codes
Copy link

Yup, upgrade to jQuery 2.x. Everything is fine now.

@jrdn91
Copy link
Author

jrdn91 commented Dec 23, 2015

I had jQuery 2.x installed and it wasn't working for me. I've switch over to the live API since then but I hope I won't have the same problems on similar projects in the future.

@samselikoff
Copy link
Collaborator

@joeegan try using the double wildcard ** in your passthrough URLs:

this.passthrough('http://ps1.pubnub.com/**');
this.passthrough('http://ps2.pubnub.com/**');
...

@NullVoxPopuli
Copy link

passthrough doesn't work for me at all.

see: https://github.com/NullVoxPopuli/aeonvera-ui

@NullVoxPopuli
Copy link

I've tried a few different ways to pass though, it seems like I can't get any of them to work with ember-cli-blanket's POST to write-blanket-coverage

this.passthrough();

  // this.passthrough('/write-blanket-coverage');
  //
  // this.passthrough('/write-blanket-coverage', ['post']);
  //
  //
  // this.post(
  //   '/write-blanket-coverage',
  //   this.passthrough
  // );
  // this.post(
  //   '/write-blanket-coverage',
  //   this.pretender.passthrough
  // );
  //
  // this.post('/write-blanket-coverage', this.pretender.passthrough);
  //
  // this.pretender.post.call(
  //   this.pretender,
  //   '/write-blanket-coverage',
  //   this.pretender.passthrough
  // );

@NullVoxPopuli
Copy link

actually, my problem might be with blanket

@kylealwyn
Copy link

** wildcard worked for me!

this.passthrough('http://a.tiles.mapbox.com/**');

@samselikoff
Copy link
Collaborator

Closing due to inactivity.

@rizkysyazuli
Copy link

rizkysyazuli commented Jul 19, 2017

I have mixed results with passthrough.

export default function() {
  this.namespace = 'api';

  ...

  // remote URLs seems to get through just fine
  this.passthrough('http://www.juicer.io/**');
  this.passthrough('http://assets.juicer.io/**');

  // but local URL keeps getting blocked
  this.passthrough('/meta');
}

This /meta is being called via ember-ajax to fetch static json files.

// app/services/common.js
export default Ember.Service.extend({
  ajax: Ember.inject.service(),

  ...

  getMeta(routeName) {
    return this._getJSON(`meta/${routeName}.json`);
  },

  ...

  _getJSON(url) {
    return this.get('ajax').request(url, {
      host: '/',
      contentType: 'application/json; charset=utf-8'
    }).catch((error) => {
      throw error;
    });
  }
});

@TarasVerbniak
Copy link

@rizkysyazuli
Try to use passthrough in route:
this.get('/meta', this.pretender.passthrough);

@shujathkhan
Copy link

@jrdn91 ِWere you able to resolve this issue, I have tried,

    this.passthrough()
    this.passthrough('https://ps14.pndsn.com/**')
    this.passthrough('https://ps3.pndsn.com/**')
    this.passthrough('https://ps8.pndsn.com/**')
    this.passthrough('https://ps1.pndsn.com/**')
    this.passthrough('https://ps15.pndsn.com/**')
    this.passthrough('https://ps19.pndsn.com/**')
    this.passthrough('https://ps**')

None of them seem to work. I am encountering this, when I am using miragejs in expo snack for react native development.

@cah-brian-gantzler
Copy link
Collaborator

If you are using react native, you might be better posting a message here. https://github.com/miragejs/miragejs/issues Most of the functionality of this addon has been abstracted to mirageJS there, including the pretender code. This addon is only left with the functionality of making it work more seamlessly with ember.

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

9 participants