How to authenticate graphql in react-admin?

Viewed 193

I'm using graphql as dataprovider. In my server, I have middleware. I'm cheking all request which come to myurl/graphql in server to authentication. I'm sendind bearer token in all request after i get token from browser. As you know graphql is not like rest api. If i use rest api, I can select exception endpoints which can go exactly to my server. So, I have to check all request in my server on graphql. Because of it, I created login endpoint out of graphql. When I send username, and password via postman, i can get ok response and cookies. Problem here, I cant send username and password on my react-admin project. Because, my graphql dataprovider manage my requests and I'm using also authprovider from react-admin. When i want to open myreactproject/login page, I'm getting 403 forbidden from my server. I tried to create custom routue to login my server, I get the same error. Is there any way to block dataproviderin custom route.


        const authLink = setContext((_, { headers }) => {
            const token = Cookies.get('accessToken')

            return {
                headers: {
                    ...headers,
                    authorization: `Bearer ${token}`
                }
            }
        })`


0 Answers
Related