Open xjjx opened 8 months ago
There's been some debate over this over the years, last one in https://github.com/jenkinsci/theme-manager-plugin/pull/76#issuecomment-1066494838
Why can't you access it over the configured Jenkins url?
For example we use separate port for HTTP2. Also some of users prefer to use just IP address, some use DNS. Could we have some configuration option to use relative paths?
Why can't you access it over 1 port using http/2 for everything?
I would accept a pull request making it configurable as either an advanced option or a system property.
Because HTTP2 is not supported everywhere. Still we want to test it. There are more users for this instance than just me :)
Can we turn around the question - why can't we just use relative links and make everyone happy? I just compiled this plugin and it works well
diff --git a/src/main/java/io/jenkins/plugins/thememanager/ThemeManagerFactory.java b/src/main/java/io/jenkins/plugins/thememanager/ThemeManagerFactory.java
index 9b04d5b..6fd090e 100644
--- a/src/main/java/io/jenkins/plugins/thememanager/ThemeManagerFactory.java
+++ b/src/main/java/io/jenkins/plugins/thememanager/ThemeManagerFactory.java
@@ -40,7 +40,8 @@ public abstract class ThemeManagerFactory extends AbstractDescribableImpl<ThemeM
*/
public String toAssetUrl(String asset) {
ThemeManagerFactoryDescriptor descriptor = getDescriptor();
- return Jenkins.get().getRootUrl() + "theme-" + descriptor.getThemeId() + "/" + asset;
+ // return Jenkins.get().getRootUrl() + "theme-" + descriptor.getThemeId() + "/" + asset;
+ return "/theme-" + descriptor.getThemeId() + "/" + asset;
}
/**
Because people run Jenkins on different context paths, you aren't able to use /
, and need to use the Jenkins configured URL.
Jenkins and plugins versions report
Theme Manager plugin add JENKINS_URL to css files. When user access Jenkins by different address than that configured as JENKINS_URL, the browser blocks some files because of:
"A cross-origin resource sharing (CORS) request was blocked because of invalid or missing response headers of the request or the associated preflight request ."
I believe links to css should be relative.
Reported also as https://issues.jenkins.io/browse/JENKINS-72816
What Operating System are you using (both controller, and any agents involved in the problem)?
Linux, official docker images for jenkins
Reproduction steps
Access jenkins by URL different that configured as JENKINS_URL
Expected Results
relative links to css files
Actual Results
blocked by browser when accessing via different url than JENKINS_URL or different port. For example we use separate port for HTTP2
Anything else?
No response
Are you interested in contributing a fix?
No response