Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpKernel] Add option to render Surrogate fragment with absolute URIs#46514
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
carsonbot commentedMay 30, 2022
Hey! I see that this is your first PR. That is great! Welcome! Symfony has acontribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
carsonbot commentedMay 31, 2022
Hey! I think@codedmonkey has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
src/Symfony/Component/HttpKernel/Tests/Fragment/SsiFragmentRendererTest.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Would it make sense not add any option and always make the URL absolute instead? |
Wouldn't be a problem to do so, but as#8879 was meant to allow relative URLs, I am not sure that it wouldn't override some users needs. Ready to update the PR in that direction if needed :) |
thanks for the pointer, let's not change that
Can't this issue be solved without adding this option? Is that problem common to all Cloudflare users or is there something specific to your use case? Did you talk to their support to understand what the issue is? Maybe it's an issue on their side? |
Kern046 commentedJun 1, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yeah absolutely. I can retrieve the right hostname from the Request URL and then make the Fragment URL absolute within the Worker's code. This issue isn't blocking, we just thought that it could be interesting that the EDIT: Furthermore I have ofc no trouble with closing this PR if you deem it unnecessary :). I understand that adding more flexibility to a method can make its responsibility more confusing and decrease the maintainability.
I think that all Cloudflare users wanting to use ESI with Symfony will get through this, because ESI with Cloudflare needs to use a Cloudflare Worker (which will intercept and parse the server response for My best guess is that Cloudflare Worker's environment is isolated and lacks some context to "guess" the current hostname to fetch a relative URL.
I just sent a message on their official Discord to get their PoV on the matter. If I'm correct about Cloudflare Worker's isolation I would say that it's not an issue but it's by design. |
Well, the worker environment has the information about the URL (as it has access to the whole Request and Response objects). But the example worker given in their blog post does not try to resolve the ESI URL as a relative URL based on that context. |
57f4a65 to0a78a2aCompareAllow usage of `absolute_uri` option when using `render_esi` or `render_ssi` in order to get absolute URIs.
0a78a2a tof9f3ed0CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
That's a simple enough change, let's do it.
Thank you@Kern046. |
Uh oh!
There was an error while loading.Please reload this page.
Context
Using ESI blocks with Cloudflare Workers we faced an issue with the
/_fragmentrelative URIs, as Cloudflare didn't succeed to handle it. We needed the absolute URL to make it work.Proposed solution
In Symfony's codebase I noticed that
Symfony\Component\HttpKernel\Fragment\FragmentUriGenerator::generatealready supports a$absoluteparameter to fit the needs offragment_uriTwig function (I even wonder if this wasn't a previously supported feature when I see#8879), but this parameter couldn't be set throughrender_esi.This PR adds the support of a new
absolute_urioption in order to set this parameter and get an absolute URI for ESI and SSI fragments. It only applies when using aControllerReferenceas the URI oraltoption. It defaults tofalseto avoid causing any BC break.Naming
I am not that confident about the naming:
absolute_urifor the option to keep it more self-descriptive than justabsolute.$absoluteto keep it more consistent with the existing parameters and usage inHttpKernelRuntime::generateFragmentUri.I have doubts about the pertinence of such a diff between the option and the variable name. Let me know what you think about it !