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

Bug Report: Absolute path on assets and links #195

Open
lifehome opened this issue Jun 20, 2021 · 1 comment · May be fixed by #196
Open

Bug Report: Absolute path on assets and links #195

lifehome opened this issue Jun 20, 2021 · 1 comment · May be fixed by #196

Comments

@lifehome
Copy link

Describe the bug

If the subspace instance is running behind a reverse proxy under a subdirectory, such as https://example.org/subspace/, the application will attempt to source the static assets from https://example.org/static/... instead of https://example.org/subspace/static/..., links and buttons will also goes to the root directory(https://example.org/logout) as well.

This is due to the hard coded absolute path inside the web templates, and can be rectified by prepending the SUBSPACE_BACKLINK variable value back into the web template.

Note: The current "Subspace" text, which sits next to the home icon on the navigation bar, is a great example demonstrating the hard coded absolute path issue.

Proposed solution

Referencing to this line:

<a class="item" href="{{.Backlink}}"><i class="home icon"></i></a>

And also these lines with absolute path issues:

<link rel="icon" href="/static/favicon.png?v={{$.Version}}">
<link rel="apple-touch-icon" href="/static/favicon.png?v={{$.Version}}">
<title>Subspace</title>
<link rel="stylesheet" type="text/css" href="/static/semantic/semantic.min.css?v={{$.Version}}">
<link rel="stylesheet" type="text/css" href="/static/style.css?v={{$.Version}}">
<link rel="stylesheet" type="text/css" href="/static/roboto.css?v={{$.Version}}">
<script src="/static/jquery.min.js?v={{$.Version}}"></script>
<script src="/static/semantic/semantic.min.js?v={{$.Version}}"></script>

It can be resolved by simply prepending the backlink template variable, for example

        <link rel="icon" href="{{.Backlink}}/static/favicon.png?v={{$.Version}}">
        <link rel="apple-touch-icon" href="{{.Backlink}}/static/favicon.png?v={{$.Version}}">

        <title>Subspace</title>

        <link rel="stylesheet" type="text/css" href="{{.Backlink}}/static/semantic/semantic.min.css?v={{$.Version}}">
        <link rel="stylesheet" type="text/css" href="{{.Backlink}}/static/style.css?v={{$.Version}}">
        <link rel="stylesheet" type="text/css" href="{{.Backlink}}/static/roboto.css?v={{$.Version}}">

        <script src="{{.Backlink}}/static/jquery.min.js?v={{$.Version}}"></script>
        <script src="{{.Backlink}}/static/semantic/semantic.min.js?v={{$.Version}}"></script>

To Reproduce

Steps to reproduce the behavior:

  1. Run a subspace instance
  2. Reverse proxy it behind nginx/swag/traefik/etc
  3. Browse the corresponding URL of the web server, which is a proxy to the subspace instance
  4. See the errors happen inside the browser console/inspector

Expected behavior

The assets and navigation links/buttons should be prepended with the backlink variable value.

Screenshots

subspace-reverseproxy-absolutepath-issue

Additional context

Sorry that I don't have time to make a PR at the very moment. However, if this issue isn't getting a fix within a week, I might squeeze some time to fix it.

@lifehome
Copy link
Author

Okey so I was going on making a PR but found that other than the template strings, the Golang files also redirects pages with absolute path... Gotta find a workaround for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant