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

Jenkins URL #248

Open
xjjx opened this issue Mar 6, 2024 · 5 comments
Open

Jenkins URL #248

xjjx opened this issue Mar 6, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@xjjx
Copy link

xjjx commented Mar 6, 2024

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

@xjjx xjjx added the bug Something isn't working label Mar 6, 2024
@timja
Copy link
Member

timja commented Mar 6, 2024

There's been some debate over this over the years,
last one in #76 (comment)

Why can't you access it over the configured Jenkins url?

@xjjx
Copy link
Author

xjjx commented Mar 8, 2024

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?

@timja
Copy link
Member

timja commented Mar 8, 2024

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.

@xjjx
Copy link
Author

xjjx commented Mar 11, 2024

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;
     }

     /**

@timja
Copy link
Member

timja commented Mar 11, 2024

Because people run Jenkins on different context paths, you aren't able to use /, and need to use the Jenkins configured URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants