feat(http): allow caching requests with different origins between ser…#55274
feat(http): allow caching requests with different origins between ser…#55274jsaguet wants to merge 1 commit intoangular:mainfrom
Conversation
c98babc to
11a6410
Compare
11a6410 to
93bb3fd
Compare
|
There is something weird with the duplicate imports in the CI. |
69e2de6 to
20a94c5
Compare
Nevermind, #55012 was merged after I created my branch, which generated conflicts. |
048d66d to
f1fe7c5
Compare
d362742 to
a4b798e
Compare
a4b798e to
48b9950
Compare
AndrewKushnir
left a comment
There was a problem hiding this comment.
@jsaguet thanks for addressing the feedback! I've left a few more comments.
82d6213 to
fb42226
Compare
fb42226 to
06d06a3
Compare
AndrewKushnir
left a comment
There was a problem hiding this comment.
Looks great, just left a couple proposals to improve error messages.
…ver and client Expose `HTTP_TRANSFER_CACHE_ORIGIN_MAP` injection token in public api. This is useful when different origins are used to access the same APIs between server and browser. Fixes angular#53702
06d06a3 to
561225e
Compare
AndrewKushnir
left a comment
There was a problem hiding this comment.
@jsaguet thanks for addressing the feedback! The change looks great 👍
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
|
@thePunderWoman could you please take a look at the public API changes when you get a chance? |
thePunderWoman
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
|
This PR was merged into the repository by commit 6f88d80. |
| throw new RuntimeError( | ||
| RuntimeErrorCode.HTTP_ORIGIN_MAP_USED_IN_CLIENT, | ||
| ngDevMode && | ||
| 'Angular detected that the `HTTP_TRANSFER_CACHE_ORIGIN_MAP` token is configured and ' + | ||
| 'present in the client side code. Please ensure that this token is only provided in the ' + | ||
| 'server code of the application.', | ||
| ); | ||
| } |
There was a problem hiding this comment.
Nice you added this warning. 👍 Otherwise the (potentially private) URLs of APIs used only-on-the-server could be disclosed in the publicly available browser-JS-bundle.
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…ver and client
Expose
HTTP_TRANSFER_CACHE_ORIGIN_MAPin public api. This token can be used when different origins are used to access the same APIs between server and browser.PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What is the current behavior?
Angular SSR applications are sometimes deployed in an internal private network where APIs must be accessed with a different origin that the external urls used from the client application.
Currently, such requests cannot be reused in the client during hydration because the urls do not match in the transfer state.
Issue Number: #53702
What is the new behavior?
Such applications can provide an origin map between server and clients by providing
HTTP_TRANSFER_CACHE_ORIGIN_MAP.The requests made on the client to the external origin will be correctly reused.
The origin map must be provided only in the server application.
A Runtime error will be thrown when the token is present in the client-side application.
Does this PR introduce a breaking change?
Other information