Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to specify $ref base url?

See original GitHub issue

I serve a frontend locally with node at localhost:8000. I pull the json schema from an API. The backend returning the json schema seats at localhost:8888 (

The schema has arrays of $ref fields in form of relative urls : var schema = [{$ref:"/api/controllers/123"},{...}].

json-schema-ref-parser resolves references relatively to the frontend url rather than the backend url. $RefParser.resolve(schema); throws the following errors:

  • request.js:114 GET http://localhost:8000/api/controllers/123 404 (Not Found)
  • index.js:67 Uncaught (in promise) Error: Error downloading http://localhost:8000/api/controllers/123.

How can I pass localhost:8888 to resolve as base url?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

dzuluagacommented, Aug 27, 2016

Awesome @BigstickCarpet. It was a bit cryptic 😉. But finally worked. Issue #13 gave me the clues. Here’s my version of the above.

  return $RefParser.dereference('./api/models/', './api/models/openapi-model.json', {})
      .then(function(dmResolved) {
        debug('data model resolved', dmResolved);
        return dmResolved;
JamesMessingercommented, Aug 27, 2016

@dzuluaga - See my reply above. You can specify the base URL as a parameter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Document Base URL element - HTML - MDN Web Docs
The HTML element specifies the base URL to use for all relative URLs in a document. There can be only one element in...
Read more >
How to specify the base URL for all relative URLs in a ...
In the below code, we have set “” as the root URL for every relative URL on the page.
Read more >
Django how to specify a base url - Stack Overflow
The best way to do this is the name your urls and then use the url template tag. Example below: First, name your...
Read more >
API Server and Base Path - Swagger
In OpenAPI 3.0, you use the servers array to specify one or more base URLs for your API. servers replaces the host ,...
Read more >
Jekyll's site.url and baseurl - Made Mistakes
Leave off trailing forward slashes when setting url. ✓ Do this, ❌ Don't do this · baseurl is not needed for most sites...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found