-
-
Notifications
You must be signed in to change notification settings - Fork 189
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get rid of configured baseUri #2157
Comments
BTW: I had a nice discussion with @kitsunet about this and he mentioned another usecase of the Also installations that are somewhere below the document root needs some considerations.. I guess that can be done with a middleware as well though |
I'm not so sure about this. I don't think the concept of
$httpRequest = ServerRequest::fromGlobals();
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($actionRequest); I would rather have that be something like: $baseUri = BaseUriProvider::fromConfiguration(); // or just inject and new Uri($baseUriSetting) or do something fancy if you like
$uriBuilder = new UriBuilder($baseUri); The fact that the |
@albe thanks for your valuable feedback once again!
I think it's at least the culprit for a lot of confusion: For the record: I don't argue against your requirements. Just to call it "baseUri" and have a global configuration doesn't make sense to me.
Sure, the example was simplified. Point is: When you use the
Yes, I agree with that. The
Not entirely. With #614 it's possible to generate absolute URLs in order to link between multiple domains (we plan to use this for Neos to get rid of the slow and ugly And, by the way:
That's still a major flaw IMO that the |
Well, not that it translates 1:1, but maybe https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI gives a good idea. I think the concept of "baseUri" is pretty well known in the web context generally. In short:
It depends (tm) :) For the case of a single website, even running on a couple alias domains with a single canonical domain, this would make sense. Also if you have a setup where the original host does not pass down to your application via some obscure proxy. Or, if you have your single-website and just want to render absolute URLs in your e-mail templates that are generated in CLI context. So I'd say: Iff your setup is a single website with one canonical URL, this global setting makes a lot of sense.
Because that falls out of the "single canonical domain website" case :) And yes, that is something that still needs to be adressed.
100% agree - just maybe the "context" shouldn't be "ActionRequest linked to an Http request", but rather a set of base- Maybe s.th. like
Let me rephrase that a bit: "you want them to be host-relative if the current baseUri (or host, see below) matches the target domain"
Those are just two other variables in the builder "context" and all variables in the context should be taken into account for the cache ofc.
100% again - though that issue is orthogonal to what we discuss here (getting rid of baseUri) |
I know and I know the documents you linked to. But it's exactly not the same thing that we use it for, i.e. the baseUri of this website is But I don't mean to split hairs and I would suggest that we focus on a potential solution since you seem to agree that it has to be addressed in general. |
Tipping in, with a usecase of baseUri i haven't thought about. I did a Flow setup on DigitalOcean Apps, and the reverse proxy stuff of theres, gave my link a url like project-distribution-ptfcd.ondigitalocean.app despite my DNS and setup in there system. Adding the baseUri in the Settings.yaml, and using a ENV for the value, solved it. Where does this response go? 😁 I have never used baseUri before in Flow, but from the documentation i could not read my way through a solution other than adding a baseUri. So as/if we remove it, let's put a task in on upgrading documentation on this topic. I can provide the distribution and environment for creating yaml configuration and test setup for this |
@sorenmalling Thanks for chiming in. Just to make sure: Isn't that what I meant with #2157 (comment) ?
I would imply that with every new/removed feature. As well as tests, but well... good that you mention it! :) |
Absolutely! Consider my comment a +1 on that 👍 (and that I clearly did not read comments before posting) |
Introduce `ActionUriBuilder` as more solid building block to create relative and absolute URLs for MVC actions. This change should not be breaking, but it deprecates some classes that were previously part of the public API: * Deprecate `UriBuilder` (in favor of the new `ActionUriBuilder`) * Deprecate `BaseUriProvider` and the use of the `Neos.Flow.http.baseUri` setting * Deprecate `ControllerContext` Related: #2157
Introduce `ActionUriBuilder` as more solid building block to create relative and absolute URLs for MVC actions. This change should not be breaking, but it deprecates some classes that were previously part of the public API: * Deprecate `UriBuilder` (in favor of the new `ActionUriBuilder`) * Deprecate `BaseUriProvider` and the use of the `Neos.Flow.http.baseUri` setting * Deprecate `ControllerContext` Related: #2157
|
|
Nice i just found out how we do it in the cli rendering for flowpack decoupled content store 😭 -> so ideally one should not need to go to such lengths and need such global configurations. |
Untying the FileSystemTarget from the baseUri is the hardest. With #3314 i could prevent Sometimes one wants to use a different base uris (hosts) for different renderings for the /**
* @var BaseUriProvider
* @Flow\Inject(lazy=false)
*/
protected $baseUriProvider;
/**
* @return callable restore the original state
*/
private function hackTheConfiguredBaseUriOfTheBaseUriProviderSingleton(UriInterface $baseUri): callable
{
assert($this->baseUriProvider instanceof BaseUriProvider);
static $originalConfiguredBaseUri;
if (!isset($originalConfiguredBaseUri)) {
$originalConfiguredBaseUri = ObjectAccess::getProperty($this->baseUriProvider, "configuredBaseUri", true);
}
ObjectAccess::setProperty($this->baseUriProvider, "configuredBaseUri", (string)$baseUri, true);
return function () use($originalConfiguredBaseUri) {
ObjectAccess::setProperty($this->baseUriProvider, "configuredBaseUri", $originalConfiguredBaseUri, true);
};
} So either Non breaking but more hacky would be to have one global place that is allowed to be mutated, which stores the currently set base uri. Instead of introducing a singleton for that i thougth about adding an environment variable |
Since the early days, Flow comes with a setting for the baseUri
But this whole concept has been source of confusion and bugs (see #2084 for example) and doesn't make sense in muliti-domain scenarios (like multi site Neos installations).
The
BaseUriProvider
that was introduced with #1755 is currently used in the following 7 places in the core packages:In all of these cases it should be possible to just fall back to the current ServerRequest (which is either available from the ActionRequest
`or can be injected (see #2144)).For cases where it's not possible to get hold of the active request (e.g. in CLI context) it can be created just like before.
For example for the
UriBuilder
:The text was updated successfully, but these errors were encountered: