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

Feat(medusajs) Allow to pass custom headers #1009

Merged
merged 5 commits into from
Feb 17, 2022

Conversation

adrien2p
Copy link
Member

@adrien2p adrien2p commented Jan 24, 2022

The request client allow to pass an argument which correspond to the custom headers that consumer would like to add to the request.

When using the wrapping of the resource, the ability to set those headers is lost.

As a consumer, using nextJS, and wanting to take advantage of getServerSideProps I am not able to set the headers coming from the request and therefore unable to send an authenticated request.
This is a huge constraint since the only other way is to rewrite the resources on my own just to add that parameters (which is already accepted by the request)

In order to fix that, the customHeaders has been added to all api method as an optional parameters (backward compatibility) and therefore a consumer is able to use the resrouces even in getServerSideProps which allow a big performance boost

@adrien2p adrien2p requested a review from a team as a code owner January 24, 2022 15:42
@adrien2p
Copy link
Member Author

@oliverheaps could you have a look please ? It will avoid that we have to override all the method when using SSR

@olivermrbl
Copy link
Contributor

@oliverheaps could you have a look please ? It will avoid that we have to override all the method when using SSR

Would it make sense to use Record<string, unknown> instead of object as mentioned in #1032? @adrien2p

@adrien2p
Copy link
Member Author

adrien2p commented Feb 14, 2022

Yes if it is accepted I can integrate it in that PR 🤘
But it will probably be Record<string, any> for the resources

@adrien2p
Copy link
Member Author

@olivermrbl it's ready when you are ready 👍

@olivermrbl
Copy link
Contributor

@olivermrbl it's ready when you are ready 👍

Great! I'll be doing some testing tomorrow and then we can wrap it up 👍

@adrien2p
Copy link
Member Author

Should work since this is the changes Ive made for my admin

@srindom srindom merged commit 22d387d into medusajs:develop Feb 17, 2022
adrien2p added a commit to adrien2p/medusa that referenced this pull request Feb 23, 2022
* Feat(medusajs) Allow to pass custom headers

* fix: axios exprexted output

* fix: integration test cart

* refactor: Update types object > Record<string, any>

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
olivermrbl pushed a commit that referenced this pull request Feb 25, 2022
* Feat(medusajs) Allow to pass custom headers

* fix: axios exprexted output

* fix: integration test cart

* refactor: Update types object > Record<string, any>

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
olivermrbl pushed a commit that referenced this pull request Mar 4, 2022
* Feat(medusajs) Allow to pass custom headers

* fix: axios exprexted output

* fix: integration test cart

* refactor: Update types object > Record<string, any>

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
SGFGOV pushed a commit to SGFGOV/medusa that referenced this pull request Apr 19, 2022
* Feat(medusajs) Allow to pass custom headers

* fix: axios exprexted output

* fix: integration test cart

* refactor: Update types object > Record<string, any>

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
SGFGOV pushed a commit to SGFGOV/medusa that referenced this pull request Apr 19, 2022
* Feat(medusajs) Allow to pass custom headers

* fix: axios exprexted output

* fix: integration test cart

* refactor: Update types object > Record<string, any>

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants