Search code examples
ember.jsember-datajson-api

Why are JSON-API links absolute


Why are the links in JSON-API responses absolute, I would have thought links relative to the api would be appropriate. An example is featured below.

{
  "links": {
    "self": "http://localhost:4200/api/v0/blog-posts?size=10",
    "first": "http://localhost:4200/api/v0/blog-posts?size=10&page=0",
    "last": "http://localhost:4200/api/v0/blog-posts?size=10&page=1",
    "next": "http://localhost:4200/api/v0/blog-posts?size=10&page=1"
  },
  ...
}

Why is it not like this?

{
  "links": {
    "self": "/blog-posts?size=10",
    "first": "/blog-posts?size=10&page=0",
    "last": "/blog-posts?size=10&page=1",
    "next": "/blog-posts?size=10&page=1"
  },
  ...
}

Solution

  • Actually, it's a bit open for interpretation https://github.com/json-api/json-api/issues/898 discussion and esp https://github.com/json-api/json-api/pull/834#issuecomment-141984604 Recommendations https://github.com/json-api/json-api/blob/f9d0cee5fe1ef4cacaa951c4354319b754506972/recommendations/index.md