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] hardcoded /css path breaks when ass isn't the root endpoint #201

Open
1 task done
ar1a opened this issue Feb 2, 2023 · 2 comments
Open
1 task done

[BUG] hardcoded /css path breaks when ass isn't the root endpoint #201

ar1a opened this issue Feb 2, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ar1a
Copy link

ar1a commented Feb 2, 2023

Is there an existing Issue for this bug?

  • I have searched the existing issues

Expected behavior

When looking at a file uploaded in the viewer, the css should be 'd under $domain/css

Actual behavior

it's hardcoded to /css

Steps to reproduce

  1. setup domain in config.json as something like ariash.ar/t
  2. upload an image
  3. observe that the page is unstyled, and /css 404s

my current setup is an apache webserver that hosts ~3 domains, and the ariash.ar domain is reverse proxied to caddy. the caddyfile looks like so:

{
        http_port 6969
        https_port 4600
}
http://ariash.ar {
        request_body {
                max_size 2000MB
        }
        root * /data/var/www/ariash.ar
        @insecure {
                header X-Forwarded-Proto http
        }
        rewrite /k /k/
        handle_path /k/* {
                file_server
        }
        handle_path /t/* {
                reverse_proxy 127.0.0.1:40115
        }
        handle {
                #redir @insecure https://ariash.ar/k
                redir https://ariash.ar/k
        }
}

and my config.json looks as so:

{
    "host": "0.0.0.0",
    "port": 40115,
    "domain": "ariash.ar/t",
    "maxUploadSize": 512,
    "isProxied": true,
    "useSsl": true,
    "resourceIdSize": 6,
    "resourceIdType": "random",
    "spaceReplace": "_",
    "gfyIdSize": 2,
    "mediaStrict": false,
    "viewDirect": false,
    "useIdInViewer": false,
    "idInViewerExtension": false,
    "dataEngine": "@tycrek/papito",
    "frontendName": "ass-x",
    "savePerDay": false,
    "adminWebhookEnabled": false,
    "s3enabled": false,
    "adminWebhookUrl": "",
    "adminWebhookUsername": "",
    "adminWebhookAvatar": "",
    "s3endpoint": "sfo3.digitaloceanspaces.com",
    "s3bucket": "bucket-name",
    "s3usePathStyle": false,
    "s3accessKey": "accessKey",
    "s3secretKey": "secretKey",
    "__WARNING__": "The following configs are no longer used and are here for backwards compatibility. For optimal use, DO NOT edit them.",
    "diskFilePath": "uploads/",
    "saveWithDate": true,
    "saveAsOriginal": false,
    "useSia": false
}

Logs (optional)

No response

ass version

0.14.2

Deployment

Docker

Operating system

debian 11

Node version

16.14.0

@ar1a ar1a added the bug Something isn't working label Feb 2, 2023
@ar1a
Copy link
Author

ar1a commented Feb 2, 2023

in the mean time, i have patched my local version with

diff --git a/views/head.pug b/views/head.pug
index ac49362..4702780 100644
--- a/views/head.pug
+++ b/views/head.pug
@@ -1,7 +1,7 @@
 meta(name='viewport' content='width=device-width, initial-scale=1.0, viewport-fit=cover')

 //- Markdown stylesheet & Highlight.js theme
-link(rel='stylesheet', href='/css')
+link(rel='stylesheet', href='/t/css')
 style: include css/dracula.highlight.js.css

 //- jQuery; Highlight.js for codeblocks; Font Awesome```

@tycrek
Copy link
Owner

tycrek commented Feb 2, 2023

ass was originally built with subdomain-based reverse proxies which is why there's no domain prefix for any of the paths. If there's more interest I could look into properly supporting path-based reverse proxies, this but I'd recommend using a Caddy rewrite rule (see image below)

Alternatively, a cheap solution I could add would be to pass the domain into the render function if it detects a path in the domain, then automatically choose /css or ${domain}/css accordingly.

image

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