-
Notifications
You must be signed in to change notification settings - Fork 14
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
Enable custom headers inside ContentResolver resolveContent #26
Comments
Hi, |
Hi, and thanks for replying so quickly! I guess we could create our own resolver inheriting ContentResolver and override resolveContent, but it felt a bit messy copy pasting the entire method. What would you recommend? Is the SDK only meant for client use? |
Got it, and there is no setting in the SSR library that does this automatically? Using cookies when making backend calls seems a bit inconvenient, but if there is no other way of achieving this I guess we need to add a method for this. The SDK is meant for Node and client-side. But in Node I would imagine one would use JWT/bearer token for authentication. |
I´m afraid there doesn´t seem to be a setting that includes cookies automatically with next.js and a server side fetch call. Fetch needs to add the cookie header manually like this to add the cookies: Regarding JWT we did a prototype using that, but it felt unneccesarily complicated setting up OpenIdDict, getting a token and keeping a corresponding session on the NextJs server, when we should be fine just passing the cookie if hosting on the same domain. |
So just to clarify, is this something I could create a pull request for? |
We do accept pull requests. Exposing a function for |
Hi!
Since the content delivery api backend supports cookie authentication (https://world.optimizely.com/documentation/developer-guides/content-delivery-api/getting-started/authorization-service/) I was thinking it might be nice to include the possibility to add a cookie header via the frontend repository.
I noticed that apiClient.ts accepts optional headers in the get-method, so what if the resolveContent method inside contentResolver.ts could be changed to include optional headers that are sent in to #api? Or maybe the ContentDeliveryConfig could be modified to include getHeaders() (like getAccessToken) and used in the call to #api.get?
(I suppose this applies to contentLoader as well)
What do you think?
The text was updated successfully, but these errors were encountered: