Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

REST base.js missing ${options.base} leads to broken relative url #21

Closed
wuyuanyi135 opened this issue Jan 15, 2016 · 2 comments
Closed

Comments

@wuyuanyi135
Copy link
Contributor

Problematic source: https://github.com/feathersjs/feathers-client/blob/master/src/rest/base.js

When executing

    var app = feathers().configure(feathers.jquery());
    var tempSwitchService = app.service('api/temp/switch');

    tempSwitchService.find().then(function(temp) {
      console.log(temp);
    });

Error: GET http://api/temp/switch net::ERR_NAME_NOT_RESOLVED

The missing ${options.base} causes the string template starting with slash, breaking a relative url. My workaround is assign base manually

    var app = feathers().configure(feathers.jquery());
    var tempSwitchService = app.service('api/temp/switch');
+   app.base='';
    tempSwitchService.find().then(function(temp) {
      console.log(temp);
    });

Suggestion: place no slash if options.base is absent.

@daffl
Copy link
Member

daffl commented Jan 15, 2016

Thank you! https://github.com/feathersjs/feathers-client/blob/master/src/rest/base.js#L16 should probably read

if(options.base) {
  this.base = `${options.base}/${this.name}`;
  delete this.options.base;
} else {
  this.base = this.name;
}

Would you mind submitting the change in a pull request? I can get a release out right away.
We're also working on a new version of a fully isomorphic Feathers client but I think it has the same problem at the moment.

wuyuanyi135 added a commit to wuyuanyi135/feathers-client that referenced this issue Jan 15, 2016
daffl added a commit that referenced this issue Jan 15, 2016
@wuyuanyi135
Copy link
Contributor Author

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants