Skip to content
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

Sending cookies with FetchTransport #122

Closed
IgnisDa opened this issue Feb 5, 2023 · 4 comments
Closed

Sending cookies with FetchTransport #122

IgnisDa opened this issue Feb 5, 2023 · 4 comments

Comments

@IgnisDa
Copy link

IgnisDa commented Feb 5, 2023

I have a cookie set in the browser that I want be sent to the backend server. However the FetchClient does not support any customization. I want to add credentials: 'include' in the constructor of the fetch request that is being sent by the browser. How can I do this?

@IgnisDa
Copy link
Author

IgnisDa commented Feb 5, 2023

@IgnisDa
Copy link
Author

IgnisDa commented Feb 5, 2023

Workaround: Add credentials: “include” in node_modules/@rspc/client/dist/index.mjs:32

@oscartbeaumont
Copy link
Member

For now, that patch is probably the best workaround.

I am currently in the process of rewriting @rspc/client and once that is done there will be a super easy way to toggle this. In the meantime the options are to:

  1. patch rspc source as you have shown (you can use patch-package if your working with a team).
  2. upgrade to a beta npm release which are undocumented, have a very different API and have an API that is going to change majorly within the next week or so.
  3. create a custom rspc transport by copying the fetch transport from the rspc source code and adding the fetch arg you need then pass it in when you initialise the client. The latest npm release is very different to the code that is in the main branch so you will need to copy the fetch transport from node_modules into your own project.

Sorry for the inconvenience here but I am hoping this new client will be a huge step forward for rspc and wanna get it right before I release it. I will leave this issue open until I have a release candidate of it out.

@IgnisDa
Copy link
Author

IgnisDa commented Feb 5, 2023

Cool. Glad to know this problem has already been accounted for. Will keep using the workaround for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants