kurenn / market_place_api

The API on Rails tutorial application
142 stars 70 forks source link

accessing the api #52

Closed jnewman12 closed 8 years ago

jnewman12 commented 8 years ago

not sure if this is the right place for this, but I'm having an issue. everything is done, tests are passing, and i deployed it to heroku. When it's actually on production, what would the address be? according to the development structure of accessing the app via http://api.repo_name.dev/, the heroku equivalent should be https://api.heroku_name.herokuapp.com right?

On development, if I go into my browser and type http://api.marketplaceapi.dev/products i get a json response. However if I make a curl request to https://api.heroku_name.herokuapp.com/products I get Heroku | No such app.

with the api subdomain set, would you know how to go about accessing the endpoints in production?

kurenn commented 8 years ago

The only thing with that, is that the app is already on a subdomain, you can change the routes files to something like this:

#From this:
namespace :api, defaults: { format: :json }, constraints: { subdomain: 'api' }, path: '/'  do
  ...
end

#To this
namespace :api, path: '/api' do
 ...
end

And you can access the api through http://heroku_name.herokuapp.com/api/any_resource

If you buy a domain for your app, you can change to the subdomain way.

jnewman12 commented 8 years ago

awesome, will do! thanks for the great resource too :)