Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to configure apiUrl for both dev and prod? #144

Closed
davidtlee opened this issue Feb 9, 2015 · 5 comments
Closed

Is there a way to configure apiUrl for both dev and prod? #144

davidtlee opened this issue Feb 9, 2015 · 5 comments

Comments

@davidtlee
Copy link

In order for me to get apiUrl to work on dev, I currently have to set it as:

$authProvider.configure({ apiUrl: 'http://localhost:3000/' });

I would like to set it as:

$authProvider.configure({ apiUrl: '/' });

so that it would be independent of dev and prod. Unfortunately, this doesn't seem to work. Does anyone have suggestions for how to do that? Thanks!

Currently I have my rails route as follows:

Rails.application.routes.draw do

  root 'angular_app#index'
  mount_devise_token_auth_for 'User', at: 'auth'

  namespace :api, defaults: { format: 'json' } do

    # List a user's rooms, create and show a room (including the messages within it)
    resources :rooms, only: [:index, :create, :show] do
      # Create and retrieve a message
      resources :messages, only: [:create], shallow: true do
      end
    end

    # Join and leave a room
    resources :participations, only: [:create, :destroy] do
    end
  end

  get '*path', to: 'angular_app#index', constraints: { path: /(?:(?!omniauth\/).)*/ }
end
@lynndylanhurley
Copy link
Owner

What is the issue when using this setting?

$authProvider.configure({ apiUrl: '/' });

@davidtlee
Copy link
Author

When I use that setting, clicking on a simple "Sign in with Google" button goes to

http://auth/google_oauth2?auth_origin_url=http%3A%2F%2Flocalhost%3A3000%2Flogin

In other words, it doesn't seem to know to append urls to the root... it should be

http://localhost:3000/auth/google_oauth2?auth_origin_url=http%3A%2F%2Flocalhost%3A3000%2Flogin

@lynndylanhurley
Copy link
Owner

@davidtlee - did you get this sorted out?

@davidtlee
Copy link
Author

nope, whoops, I must've accidentally closed it.

@davidtlee davidtlee reopened this Feb 9, 2015
@davidtlee
Copy link
Author

So I didn't fix it, but now the problem is no longer relevant since I just decided to change to:

$authProvider.configure({ apiUrl: 'api' });

and then change the rails route to:

mount_devise_token_auth_for 'User', at: 'api/auth'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants