Stirling-Tools / Stirling-PDF

#1 Locally hosted web application that allows you to perform various operations on PDF files
https://stirlingpdf.com
MIT License
43.64k stars 3.55k forks source link

[Bug]: Favicon customization #2012

Open andrelcm opened 1 day ago

andrelcm commented 1 day ago

Installation Method

Docker

The Problem

Hi everyone, I followed the instructions I found here (https://github.com/Stirling-Tools/Stirling-PDF/issues/433) in order to change the favicon. I made new versions to all images that can be found in static folder. For the "favicon.svg", everything is fine, the image is loaded in main page. The problem is with browser favicon, the one in the title bar. It does not load my image, but the default one of Stirling. I tried downloading those images with wget from command line and discovered that the request is being redirected to root folder (which is not an image, of course). Am I doing something wrong? What could I investigate to try to solve this problem?

Version of Stirling-PDF

latest-fat (as today)

Last Working Version of Stirling-PDF

No response

Page Where the Problem Occurred

http://localhost:8080/favicon.ico

Docker Configuration

services:
  stirling-pdf:
    image: frooodle/s-pdf:latest-fat
    container_name: pdf
    restart: always
    ports:
      - '8080:8080'
    volumes:
      - ./trainingData:/usr/share/tessdata
      - ./extraConfigs:/configs
      - ./customFiles:/customFiles/
      - ./logs:/logs/
    environment:
      - DOCKER_ENABLE_SECURITY=false
      - INSTALL_BOOK_AND_ADVANCED_HTML_OPS=false
      - LANGS=pt_BR

Relevant Log Output

I cannot see anything relevant here:

2024-10-14 12:21:44,840 INFO s.s.S.SPdfApplication [main] Starting SPdfApplication v0.29.0 using Java 21.0.4 with PID 9 (/app.jar started by stirlingpdfuser in /)
2024-10-14 12:21:44,841 INFO s.s.S.SPdfApplication [main] The following 1 profile is active: "default"
2024-10-14 12:21:49,229 INFO s.s.S.SPdfApplication [main] Running configs ApplicationProperties(legal=ApplicationProperties.Legal(termsAndConditions=, privacyPolicy=, accessibilityStatement=, cookiePolicy=, impressum=), security=ApplicationProperties.Security(enableLogin=true, csrfDisabled=false, initialLogin=ApplicationProperties.Security.InitialLogin(username=...), oauth2=ApplicationProperties.Security.OAUTH2(enabled=false, issuer=, clientId=, autoCreateUser=false, blockRegistration=false, useAsUsername=email, scopes=[openid, profile, email], provider=google, client=ApplicationProperties.Security.OAUTH2.Client(google=Google [clientId=, clientSecret=NULL, scopes=[https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile], useAsUsername=email], github=GitHub [clientId=, clientSecret=NULL, scopes=[read:user], useAsUsername=login], keycloak=Keycloak [issuer=, clientId=, clientSecret=NULL, scopes=[openid, profile, email], useAsUsername=preferred_username])), loginAttemptCount=5, loginResetTimeMinutes=120, loginMethod=normal), system=ApplicationProperties.System(defaultLocale=pt-BR, googlevisibility=false, showUpdate=true, showUpdateOnlyAdmin=false, customHTMLFiles=false, tessdataDir=/usr/share/tessdata, enableAlphaFunctionality=false), ui=ApplicationProperties.Ui(appName=..., homeDescription=..., appNameNavbar=...), endpoints=ApplicationProperties.Endpoints(toRemove=[], groupsToRemove=[]), metrics=ApplicationProperties.Metrics(enabled=true), automaticallyGenerated=ApplicationProperties.AutomaticallyGenerated(), enterpriseEdition=ApplicationProperties.EnterpriseEdition(customMetadata=ApplicationProperties.EnterpriseEdition.CustomMetadata(autoUpdateMetadata=true, author=username, creator=Stirling-PDF, producer=Stirling-PDF)), autoPipeline=ApplicationProperties.AutoPipeline(outputFolder=null))
2024-10-14 12:21:49,254 INFO s.s.S.c.EndpointConfiguration [main] Disabling pdf-to-book
2024-10-14 12:21:49,254 INFO s.s.S.c.EndpointConfiguration [main] Disabling book-to-pdf
2024-10-14 12:21:49,426 INFO s.s.S.c.s.d.DatabaseBackupHelper [main] Deleted oldest backup: backup_202410141100.sql
2024-10-14 12:21:49,431 INFO s.s.S.c.s.d.DatabaseBackupHelper [main] Database export completed: configs/db/backup/backup_202410141221.sql
2024-10-14 12:21:50,602 INFO s.s.S.SPdfApplication [main] Started SPdfApplication in 6.193 seconds (process running for 6.765)
2024-10-14 12:21:50,607 WARN s.s.S.u.FileMonitor [scheduling-1] not monitoring any directory, even the root directory itself: ./pipeline/watchedFolders
2024-10-14 12:21:50,608 INFO s.s.S.u.FileMonitor [scheduling-1] Registered directory: ./pipeline/watchedFolders
2024-10-14 12:21:51,608 INFO s.s.S.SPdfApplication [main] Stirling-PDF Started.
2024-10-14 12:21:51,608 INFO s.s.S.SPdfApplication [main] Navigate to http://localhost:8080
2024-10-14 12:22:17,870 INFO s.s.S.c.s.s.CustomHttpSessionListener [qtp1762039910-68] Session created: node0hu4kl9yj91nx1irv0swul5kea0

Additional Information

Just to emphasize that "favicon.svg" works flawlessly, but the other icons, which are at the exact same location, not.

Browsers Affected

No response

No Duplicate of the Issue

Frooodle commented 1 day ago

Have you tired making a favicon.ico to override the existing one etc?

andrelcm commented 21 hours ago

Yes, I did. I made my own version of all favicons I saw in static folder in repository. However, despite using the same method for all, only favicon.svg worked.

Frooodle commented 20 hours ago

Could be a cache issue, have you reloaded browser cache?

andrelcm commented 16 hours ago

I don't think it is a caching issue. Please, look at the response headers (and codes) when I try to download the proper files:

favicon.svg: curl -I http://localhost:8080/favicon.svg

HTTP/1.1 200 OK
Date: Mon, 14 Oct 2024 21:34:32 GMT
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Last-Modified: Mon, 14 Oct 2024 10:59:14 GMT
Content-Type: image/svg+xml
Accept-Ranges: bytes
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Length: 3367849

favicon.ico: curl -I http://localhost:8080/favicon.ico

HTTP/1.1 302 Found
Date: Mon, 14 Oct 2024 21:35:29 GMT
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Location: http://localhost:8080/login
Content-Length: 0

favicon-32x32.png: curl -I http://localhost:8080/favicon-32x32.png

HTTP/1.1 302 Found
Date: Mon, 14 Oct 2024 21:36:29 GMT
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Location: http://localhost:8080/login
Content-Length: 0

As you can see, only favicon.svg, the file that works, has a response code 200. All the others, regardless of its presence on static folder have the code 302, pointing to login page. This happens even for other type of files, like site.webmanifest. I can even ask for nonexisting files and the response will be the same: 302. Below, a screenshot of network tab in chrome, during page load (you can see the 302 - redirect codes for favicon files): Screenshot from 2024-10-14 18-41-37