vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
MIT License
5.39k stars 943 forks source link

fix(cookies): Apply split cookie session middleware per route #2880

Closed gdarchen closed 3 weeks ago

gdarchen commented 3 weeks ago

Description

When using split cookies to have different cookie name for the shop-api and the admin-api, we used to apply the cookieSession() middleware globally.

However, Nest Global Middlewares can't be applied to specific routes. By doing Global Middlewares, the last applied app.use() middleware was overriding the above-mentioned ones.

Instead, we have to use Functional Middlewares for the specific paths we like.

As a consequence, for the case when the user wants to split the cookies, we do not do it in the bootstrap() function any longer but instead we do it in the AppModule.configure() method, where other middlewares route-specific are already applied.

Breaking changes

There is no breaking change as we just fix a behaviour that was not working.

Screenshots

N/A

Checklist

πŸ“Œ Always:

πŸ‘ Most of the time:

netlify[bot] commented 3 weeks ago

Deploy Preview for effervescent-donut-4977b2 canceled.

Name Link
Latest commit 54a753b2faf500e48090491e6144992d02e88733
Latest deploy log https://app.netlify.com/sites/effervescent-donut-4977b2/deploys/6661757a8a18bc000870ed6d
michaelbromley commented 3 weeks ago

Thanks for the fix πŸ‘