Project

General

Profile

Actions

Bug #97324

open

CSS / JS files not referenced correctly when concatenation and compression are disabled

Added by Marco Kuprat about 2 years ago. Updated 9 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2022-04-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

After updating a site from TYPO3 10.4 to 11.5.8 I encountered following problem:
The frontend of subpages from level 2 got messed up, because CSS and JS files were not referenced correctly (loading those files resulted in a 404 error).

Example TypoScript setup in order to reproduce the error:

config.minifyCSS = 0
config.concatenateCss = 0
config.compressCss = 0
config.minifyJs = 0
config.concatenateJs = 0
config.compressJs = 0

page.includeCSS.mycss = fileadmin/mycss.css
page.includeJS.myjs = fileadmin/myjs.js

In TYPO3 11.5 the CSS and JS files are referenced like this:
<link rel="stylesheet" type="text/css" href="fileadmin/mycss.css">
<script src="fileadmin/myjs.js?1570519026"></script>

Whereas in TYPO3 10.4 they were referenced with a prepending slash:
<link rel="stylesheet" type="text/css" href="/fileadmin/mycss.css">
<script src="/fileadmin/myjs.js?1570519026"></script>

So on subpages like https://www.domain.xy/page-1/subpage-1-1/ the references lead to a 404 error.

Setting config.absRefPrefix = / (or any other values) in TypoScript does not help.
However it works when config.baseURL is set, but that is deprecated.
Also, the problem does not exist as soon as config.concatenateCss = 1 or config.compressCSS = 1 are set (JS respectively), because in that case the references look like " /typo3temp/assets/compressed... "


Related issues 2 (2 open0 closed)

Related to TYPO3 Core - Bug #99135: page.includeCSS with resource from fileadmin, the beginning slash is missing TYPO3 11.5.19New2022-11-19

Actions
Related to TYPO3 Core - Bug #82574: Inconsistent support of config.absRefPrefix in fluid/extbaseNew2017-09-28

Actions
Actions #1

Updated by Marco Kuprat about 2 years ago

  • Project changed from 9 to TYPO3 Core
  • TYPO3 Version set to 11
  • PHP Version set to 7.4
Actions #2

Updated by Česlav Przywara about 2 years ago

A bit off topic: where did you get that config.baseURL is deprecated?

Looking at 11.5 docs, I don't see any deprecation being mentioned: https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/Setup/Config/Index.html#baseurl

Actions #3

Updated by Marco Kuprat about 2 years ago

That's right, "deprecated" is the wrong wording.
But with the possibility of site management since TYPO3 9 there's normally no need for config.baseURL anymore.

My frontend was OK without config.baseURL when the site was running TYPO3 10.4. But after the upgrade to TYPO3 11.5 it crashed and I regard setting config.baseURL as workaround.
Of course, you could also add preceding slashes to page.includeCSS and page.includeJS in order to solve the problem.
But on the other hand I don't see a requirement for that in the docs.

So, all in all I regard this as a bug or at least missing documentation.

Actions #4

Updated by Riccardo De Contardi almost 2 years ago

  • Category set to Frontend
Actions #5

Updated by Arne Bracht over 1 year ago

  • Related to Bug #99135: page.includeCSS with resource from fileadmin, the beginning slash is missing TYPO3 11.5.19 added
Actions #6

Updated by Knut E. about 1 year ago

A bit off topic: where did you get that config.baseURL is deprecated?

deprecated in TYPO3 Version 12.1

so the question for me what to do: the effect ist still in TYPO3 11.5.26: Add a Slash at the beginning of the files or is there another solution?

Actions #7

Updated by Knut E. about 1 year ago

a possible Solution via site:base from siteconfiguration

page = PAGE
page.headTag.append = TEXT
page.headTag.append.dataWrap = <base href="{site:base}">

Actions #8

Updated by Riccardo De Contardi 9 months ago

Knut E. wrote in #note-6:

so the question for me what to do: the effect ist still in TYPO3 11.5.26: Add a Slash at the beginning of the files or is there another solution?

Is there a reason not to write directly:

page.includeJS.myjs = /fileadmin/myjs.js

?

Actions #9

Updated by Riccardo De Contardi 9 months ago

  • Related to Bug #82574: Inconsistent support of config.absRefPrefix in fluid/extbase added
Actions #10

Updated by Knut E. 9 months ago

Is there a reason not to write directly:

[...]

?

I think both solutions work. The leading slash you have to add to every file. If there are extensions or more files it can be a little bit faster with the other workaround. I don't know if a solution is preferable.

Actions

Also available in: Atom PDF