Skip to content

request.url does not seem to include the prefix or version #174

Closed
@dvandersluis

Description

@dvandersluis

As part of the authentication scheme for my API, the URL the consumer accessed is hashed as part of an authentication token. However, when I access request.url in my authentication code, the API prefix and the API version specified are not reflected in the URL:

class API < Grape::API
  error_format :json

  use API::Auth, :token_class => "ApiToken"

  version 'v1', :using => :path
  prefix 'api'

  resources :employees do
    get do
      Employee.all
    end
  end
end

If I GET /api/v1/employees.json, request.url is set to http://www.example.com//employees (note the double slash). Since the consumer, however, is (properly) using http://www.example.com/api/v1/employees as the URL, the URL on each side does not match up and authentication fails.

Any ideas how to fix or get around this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions