fix: SsrCookieService to support Express request objects in Angular SSR - #361
Closed
pavankjadda with Copilot wants to merge 3 commits into
Closed
fix: SsrCookieService to support Express request objects in Angular SSR#361pavankjadda with Copilot wants to merge 3 commits into
pavankjadda with Copilot wants to merge 3 commits into
Conversation
…est objects Co-authored-by: pavankjadda <17564080+pavankjadda@users.noreply.github.com>
Co-authored-by: pavankjadda <17564080+pavankjadda@users.noreply.github.com>
|
Copilot
AI
changed the title
[WIP] this.request.headers.get is no a function
Fix SsrCookieService to support Express request objects in Angular SSR
Aug 5, 2025
Collaborator
|
Closes in favor of #362 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The
SsrCookieServicewas failing when users passed Express request objects directly to Angular'sREQUESTtoken during server-side rendering. The service expected Angular'sREQUESTobject which has aheaders.get()method, but Express request objects have a different API structure.Error encountered:
Root cause:
The service was calling
this.request?.headers.get('cookie')in three places (check(),get(), andgetAll()methods), but Express request objects don't have aheaders.get()method. Instead, they have:req.get('cookie')method for getting headersreq.headers.cookieproperty for direct header accessSolution:
Added a private
getCookieHeader()method that safely handles multiple request object types:headers.get('cookie')methodget('cookie')method with fallback toget('Cookie')headers.cookieorheaders.Cookieproperty accessThe fix maintains backward compatibility while adding support for Express request objects commonly used in Angular Universal SSR setups.
Changes:
getCookieHeader()private method with type-safe request handlingthis.request?.headers.get('cookie')with the new helperSameSitetype locallyUsage example that now works:
Fixes #346.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
accounts.google.com/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3458 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-31405678 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15117442920883301777,5975249126760531825,262144 --disable-features=PaintHolding --variations-seed-version(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-31405678 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=31405678(dns block)/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3929 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-35746611 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4279227157114855908,17699770739712919255,262144 --disable-features=PaintHolding --variations-seed-version(dns block)clients2.google.com/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3458 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-31405678 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15117442920883301777,5975249126760531825,262144 --disable-features=PaintHolding --variations-seed-version(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-31405678 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=31405678(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-35746611 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=35746611(dns block)clientservices.googleapis.com/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3458 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-31405678 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15117442920883301777,5975249126760531825,262144 --disable-features=PaintHolding --variations-seed-version(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-31405678 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=31405678(dns block)/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3929 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-35746611 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4279227157114855908,17699770739712919255,262144 --disable-features=PaintHolding --variations-seed-version(dns block)redirector.gvt1.com/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3458 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-31405678 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15117442920883301777,5975249126760531825,262144 --disable-features=PaintHolding --variations-seed-version(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-31405678 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=31405678(dns block)/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3929 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-35746611 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4279227157114855908,17699770739712919255,262144 --disable-features=PaintHolding --variations-seed-version(dns block)safebrowsingohttpgateway.googleapis.com/opt/google/chrome/chrome --user-data-dir=/tmp/karma-31405678 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=31405678(dns block)/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3458 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-31405678 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15117442920883301777,5975249126760531825,262144 --disable-features=PaintHolding --variations-seed-version(dns block)/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3929 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-35746611 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4279227157114855908,17699770739712919255,262144 --disable-features=PaintHolding --variations-seed-version(dns block)www.google-analytics.comng test ngx-cookie-service --watch=false --browsers=ChromeHeadless(dns block)ng test ngx-cookie-service-ssr(dns block)ng build ngx-cookie-service-ssr(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.