Skip to content
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

Backend preview URL does not work #5582

Closed
fritzmg opened this issue Dec 15, 2022 · 6 comments
Closed

Backend preview URL does not work #5582

fritzmg opened this issue Dec 15, 2022 · 6 comments
Assignees
Labels
Milestone

Comments

@fritzmg
Copy link
Contributor

fritzmg commented Dec 15, 2022

Affected version(s)

5.0.7, 5.0.x-dev

Description

If you open the preview from the back end, i.e. via an URL like

https://example.com/contao/preview?page=8

then the resulting redirect response URL will be

https://example.com\/preview.php/page-alias

which will lead to a 404 response.

For some reason this call in PageModel::getPreviewUrl

$strUrl = $objRouter->generate(PageRoute::PAGE_BASED_ROUTE_NAME, array(RouteObjectInterface::CONTENT_OBJECT => $this, 'parameters' => $strParams), UrlGeneratorInterface::ABSOLUTE_URL);

results in such an aforementioned URL (with the first slash "escaped").

/cc @aschempp

@fritzmg fritzmg added this to the 5.0 milestone Dec 15, 2022
@ausi
Copy link
Member

ausi commented Dec 15, 2022

I was not able to reproduce this with Contao 5.0.7

For a request to /contao/preview?page=4
I first get a response with:
Location: /preview.php/contao/preview?page=4
and the second response with:
Location: https://example.com/preview.php/test-page.html

@fritzmg
Copy link
Contributor Author

fritzmg commented Dec 15, 2022

Hm, I can reproduce it in 5.0.7 and 5.0.x-dev.

@fritzmg
Copy link
Contributor Author

fritzmg commented Dec 15, 2022

It's an issue that only occurs under Windows, presumably. The cause is this line:

$context->setBaseUrl(rtrim(\dirname($baseUrl), '/') . $previewScript);

$baseUrl is /preview.php and \dirname($baseUrl) will be \.

@fritzmg
Copy link
Contributor Author

fritzmg commented Dec 15, 2022

This change was introduced here: #5195

$previewScript is /preview.php in both Contao 4.13 and 5.0 - yet for some reason we handle it differently in Contao 5? @ausi do you remember why?

@fritzmg
Copy link
Contributor Author

fritzmg commented Dec 15, 2022

My bad, I changed this here: #4326 🙈

@fritzmg
Copy link
Contributor Author

fritzmg commented Dec 15, 2022

Closing in favor of #5585

@fritzmg fritzmg closed this as completed Dec 15, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants