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
Live queries with axios interceptor don't work #278
Comments
Hi @mihaa1, The default implementation for the SubscriptionClient used in this tutorial, uses the browser's EventSource object that doesn't support adding header elements But don't worry, you don't need it - because registering the the To get a message, the live query subscribes to a channel, using the normal http call, in your case axios, and will have the authorization header - so there is no data leak risk here. Alternatively, you can implement an alternative implementation of the SubscriptionClient that uses fetch, here's a popular fetch client: You can create an adapter for it, the entire adapter for the EventSource is only 100 lines of code, so creating an adapter should be easy enough. All that said - I stand by the first option where you don't need the jwt for the stream, as registering to the stream doesn't give you any message Let me know if that works |
Hi, I have the same problem.
I tried to follow the tutorial, but it appears that the code is no longer applicable to the current version, as there is no 'remult.setUser()' function, etc. Thanks, Alex |
Hi, These tutorials no longer use axios and JWT - instead, they use 'cookie-session' If you do want to have JWT - here's an example of how I got it to work without the exclude paths... Here's the specific commit: Let me know if that helps |
Thanks. Will try to understand how it works... I just moved to axios in order to be able to set the authorization... In your example the "fetch" is used... Alex |
@alexchern you don't really need axios for that - but if you want to use axios, you can do the same with the intercepters there. Let me know how it worked or if you need more help |
Thanks a lot. Once again, thanks for your support, Alex |
Hi @impleotv , The quick solution would be to handle the response back from fetch - and based on it simply redirect to the login page: Or - you can move the code that set's the httpClient, into the component and tell it to do some react thing (navigate) when there is an error |
When using live queries + axios interceptor to inject jwt - request api/stream doesn't get it.
Expected behavior
interceptor catches these requests as well to authenticate in server
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: