Giter Site home page Giter Site logo

Comments (3)

kgish avatar kgish commented on August 22, 2024

I found out where to hack it, but you probably want a more elegant fix that is configurable.

In the file client.js see the lines marked <== FIXED

...
HAL.Http.Client.prototype.get = function(url) {
  var self = this;
  this.vent.trigger('location-change', { url: url });
  var jqxhr = $.ajax({
    url: 'http://localhost:8080'+url, // <== FIX
    dataType: 'json',
    success: function(resource, textStatus, jqXHR) {
    ...
  });
};

HAL.Http.Client.prototype.request = function(opts) {
  var self = this;
  opts.dataType = 'json';
  opts.url ='http://localhost:8080'+opts.url; // <== FIX
  ...
};
...

from hal-browser.

xogeny avatar xogeny commented on August 22, 2024

Isn't the "correct" answer here to follow Section 5 "Reference Resolution" of RFC 3986 "Uniform Resource Identifier (URI): Generic Syntax"?

The main issue, if I understand it, is establishing a base URI. But if I visit:

http://haltalk.herokuapp.com/explorer/browser.html#http://localhost:3000

It seems clear that the base URI is http://localhost:3000 (since that is the URI that the request was made to). So if the response from http://localhost:3000 includes a link of the form /foo, shouldn't that be normalized into "http://localhost:3000/foo". The current version on Heroku simply attempts to use /foo (which, I take it, is the issue you are concerned about?).

from hal-browser.

xogeny avatar xogeny commented on August 22, 2024

OK, so I had this same issue and I wasn't really able to test my API because it lacks support for handling relative URIs in the HAL API. The changes required are not actually in client.js. The reason is that you need to have some context and client.js doesn't have that. But I looked through the code and I adjusted things so that it resolves relative URIs at the time it renders the page in browser.html.

I've submitted a pull request to adds support for relative URIs for anyone who is interested.

from hal-browser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.