Skip to content

Make acts_as_resource_controller's base_url method be compatible with custom Rails config.relative_url_root #473

@masda70

Description

@masda70

Right now, if the Rails app uses a custom relative_url_root, the JSONAPI link builder will use the wrong base url to build its links.

In my own app, I set for instance config.relative_url_root = '/api', and this change broke my app. I had to override the ResourceController's base_url method to fix this.

  def base_url
    @base_url ||= request.protocol + request.host_with_port + self.config.relative_url_root
  end

lib/jsonapi/acts_as_resource_controller.rb could use something like that as new default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions