josx / ra-data-feathers

A feathers rest client for react-admin
MIT License
157 stars 53 forks source link

No redirect to login after API returns 401 #155

Closed dannymatkovsky closed 3 years ago

dannymatkovsky commented 3 years ago

React-admin gets the 401 response from Feathers API, but nothing happens, no redirect to login page.

App.js:

import React from 'react';
import feathers from '@feathersjs/feathers';
import rest from '@feathersjs/rest-client';
import { restClient, authClient } from 'ra-data-feathers';

const client = feathers().configure(
  rest('http://localhost:3030').fetch(window.fetch)
);

const App = () => (
  <Admin
    dataProvider={restClient(client, {id: '_id'})}
    authProvider={authClient(client)}
  >
    <Resource name="news" list={ListGuesser} />
  </Admin>
);

React-admin v.3.14.2 Ra-data-feathers v.2.8.1

dannymatkovsky commented 3 years ago

According to the official docs

When authProvider.checkError() returns a rejected Promise, react-admin redirects to the /login page, or to the error.redirectTo URL.

But there is no checkError property in authProvider that I get by authClient(client) function. It's not even an object

josx commented 3 years ago

Maybe you can debug it, also check redirectTo (maybe it is not working with default value).

dannymatkovsky commented 3 years ago

I had wrong Feathers configuration. Sorry. Closing the issue.