0

In my Angular app config I have:

$httpProvider.defaults.headers.common['Custom-Auth-Token'] = ____; $httpProvider.defaults.headers.common['Custom-Auth-Signature'] = ____;

These headers are necessary in order to make ANY API requests to the Rails backend server.

On my Rails backend, I'm using Sorcery and have access to current_user.authentication_token in my controller/views. I thus need to pass this to the angular config.js.erb. Is this even possible?

Another issue I have is that the auth-token will then be hashed with an app secret (this is only available on the Rails server and shouldn't ever be seen in the JavaScript), which becomes the auth-signature. How do I perform this action on the rails side, then pass this to Angular's config?

1 Answer 1

1

You could put this information in data attribute of a HTML tag. From the Angular app in your frontend you just have to fetch this tag with his id and get the data from it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, works great! I really wish there was a way to pass a rails variable directly though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.