title: Rails route for api on subdomain
body: <p>I want to make the API of my Rails app accessible through a subdomain (https://api.domain.com). I have the following routes defined:</p>
  
  <pre><code>constraints :subdomain =&gt; 'api' do
    namespace :api, defaults: {format: 'json'} do
      scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do
        resources :posts
      end
    end
  end
  </code></pre>
  
  <p>This works but results in the following url:</p>
  
  <pre><code>https://api.domain.com/api/posts
  </code></pre>
  
  <p>I would like it to be:</p>
  
  <pre><code>https://api.domain.com/posts
  </code></pre>
  
  <p>The API controllers are in <strong>app/controllers/api/v1</strong> where they should stay.</p>
  
  <p>I tried mapping the route but without any success. Does somebody know how to fix this?</p>