custom authProvider - Passing API Url
Hi!
I currently have a custom authProvider that queries the /auth/login endpoint of my API. Right now, I have the URL in a const _app.tsx /and/ in authProvider.
Is there a way where I can just pass the URL to authProvider?
5 Replies
magic-beige•17mo ago
Hi @avangeous
I don't understand your question. You want to send a request to the AuthProvider's methods, for example to the
login
method with a dynamic url?
For this case you can pass a value to the useLogin
hook and use the same name in the AuthProvider.
sunny-greenOP•17mo ago
Poorly worded, sorry. I need authProvider to use my dataProvider to query my
/auth/login
endpoint.
Right now its
But I'd rather get rid of this userProvider and just use dataProvider, if that's possible.optimistic-gold•8mo ago
@kapa.ai How can I get the Api url that I provided to the dataprovider in the authprovider?
Let me check the knowledge base for you. One moment! :books:
----------------------
In Refine, the
getApiUrl
method is used to return the apiUrl
value that you provided to the dataProvider
. This method can be consumed using the useApiUrl
data hook. Here is an example of how you can define the getApiUrl
method in your dataProvider
:
In the authProvider
, you can use the getApiUrl
method to get the apiUrl
value. However, please note that the getApiUrl
method is not directly related to the authProvider
. The authProvider
is more concerned with authentication-related operations such as login, check, logout, and error handling.
For more information, you can refer to the Refine documentation (https://refine.dev/docs/data/data-provider#getapiurl-).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@490961337896402944> kapa.ai is still learning and improving, please let us know how it did by reacting below