Blazor Web (InteractiveAuto) with BFF + YARP and token exchange api call sample#384
Conversation
kevinchalet
left a comment
There was a problem hiding this comment.
Thanks for this great PR! 👏🏻
samples/Geonosis/Geonosis.Auth/Services/DatabaseCreatorSeederWorker.cs
Outdated
Show resolved
Hide resolved
samples/Geonosis/Geonosis.Ui/Geonosis.Ui/AuthenticationEndpointsExtensions.cs
Outdated
Show resolved
Hide resolved
samples/Geonosis/Geonosis.Ui/Geonosis.Ui/AuthenticationEndpointsExtensions.cs
Outdated
Show resolved
Hide resolved
| transformContext.ProxyRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", exchangeResult.IssuedToken); | ||
|
|
||
| // Remove application cookies | ||
| transformContext.HttpContext.Request.Headers.Remove("Cookie"); |
There was a problem hiding this comment.
I guess you're doing that to prevent the Cookie header from being propagated to the downstream API? If so, I'm not sure it really works as you expect (and mutating the original HttpRequest isn't ideal anyway).
Consider using transformBuilder.RequestTransforms.Add(new RequestHeaderRemoveTransform("Cookie")) instead 😃
There was a problem hiding this comment.
I retested my code without removing cookies, and now everything works. My first attempt solved some issues with the API call, but now it seems to be no longer necessary.
There was a problem hiding this comment.
Removing the cookies isn't a bad idea at all (no point sending cookies that won't be used by the API).
Let's add transformBuilder.RequestTransforms.Add(new RequestHeaderRemoveTransform("Cookie")), it's the simplest option.
Co-authored-by: Kévin Chalet <kevinchalet@gmail.com>
samples/Geonosis/Geonosis.Auth/Services/DatabaseCreatorSeederWorker.cs
Outdated
Show resolved
Hide resolved
…orker.cs Co-authored-by: Kévin Chalet <kevinchalet@gmail.com>
|
Merged, thanks for your PR, @m3nax! 🎉 |
Esempio blazor che fa uso di BFF with YARP e token exchange.
Pages:
Related to #367