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

404 on resources when custom path #3618

Closed
anthosz opened this issue May 23, 2019 · 18 comments
Closed

404 on resources when custom path #3618

anthosz opened this issue May 23, 2019 · 18 comments
Labels

Comments

@anthosz
Copy link

anthosz commented May 23, 2019

Hello,

Following issue #2977 and a request to slack. I cannot install cachet with a custom path.

Example: http://127.0.0.1/cachet
APP URL is the same in all case.

If I add RewriteBase, only page seems to works but 127.0.0.1/cachet/setup/ cannot load ressources (like js/css...etc). Indeed, the browser try to get resources from 127.0.0.1/build/... instead 127.0.0.1/cachet/build/...

If I don't add RewriteBase, I have 404 for all pages but ressources links are ok..

Versions:
Apache 2.4
Php 7.2
Cachet 2.3.18

Best regards,

@welcome
Copy link

welcome bot commented May 23, 2019

👋 Thank you for opening your first issue. I'm just an automated bot that's here to help you get the information you need quicker, so please ignore this message if it doesn't apply to your issue.
If you're looking for support, you should try the Slack group by registering your email address at https://cachethq-slack.herokuapp.com. Alternatively, email [email protected] for our Professional support service (please note, this a paid service.)
If you're issue is with documentation, you can suggest edits by clicking the Suggest Edits link on any page, or open an issue at https://github.com/CachetHQ/Docs

@anthosz
Copy link
Author

anthosz commented May 24, 2019

I just find public/build/rev-manifest.json but it's not absolute path.

The goal is to find where is generated "/build" & to force the root path before..

@nalysius
Copy link
Contributor

Hello,

Thank you for coming from Slack to here. I'll try to illustrate the issue, and check in the code what we have to do.

Firstly, to illustrate your problem (if I correctly understand it), here is a screenshot of the setup page.

cachet-setup-no-rewrite-base

On my fresh install the URL is http://localhost/cachet/Cachet/public/index.php/setup. I've set no virtual host in Apache, I use the default one here.
The problem on this page is some requests are not using the APP_BASE environment variable as a base path. An example of request is /dist/css/all-2812406e36.css, the path is given as absolute and the environment variable is not used.

nalysius added a commit to nalysius/Cachet that referenced this issue May 24, 2019
Cachet may be installed at the root of its vhost or in a subdirectory,
for example in "/" or under "/status".

The URI we found pointing to some assets were usually not prefixed with
the APP_URL value, so if Cachet was installed under "/status" the asset
URI pointed to the server root like "/my-asset.js".
It is a problem because that means the behaviour is broken in this case.
The problem was present from the setup, it was not possible to fill the
setup since the path to the scripts and CSS weres wrong.

The content of the APP_URL environment variable is now read and used
in the assets URI.

See: cachethq#3618
@anthosz
Copy link
Author

anthosz commented May 27, 2019

Thank you @anthonybocci ,

This is exactly the issue that I have.

For now I use mod_substitue to rewrite body on the fly but it's pretty dirty:

AddOutputFilterByType SUBSTITUTE text/html text/css application/javascript
Substitute "s@/(auth|setup|build|img)@/cachet/$1@i"

Best regards,

@nalysius
Copy link
Contributor

@anthosz thank you for sharing your workaround. I've understood the problem, I just need to fix one thing and it will be ok.

The error your said before updating your message about a count function waiting for an instance of Countable is because you were using PHP 7.2. Cachet is PHP 7.2-compatible from the version 2.4~dev. Not 2.3.X.

@anthosz
Copy link
Author

anthosz commented May 27, 2019

@anthonybocci

I confirm that the error (count) has been fixed in 2.4 (dev).

Please note btw that we have the same issue on 2.4 concerning resources call.

Workaround for 2.4:

AddOutputFilterByType SUBSTITUTE text/html text/css application/javascript
Substitute "s@/(auth|metrics|build|dashboard/api|dist)@/cachet/$1@i"
Substitute "s@/(fonts/)@/cachet/$1@i"

But the path of fonts/, metrics/ and dashboard are ok once logged but not ok when not logged (anonymous).

Best regards,

nalysius added a commit to nalysius/Cachet that referenced this issue Jun 8, 2019
Cachet may be installed at the root of its vhost or in a subdirectory,
for example in "/" or under "/status".

The URI we found pointing to some assets were usually not prefixed with
the path, so if Cachet was installed under "/status" the asset
URI pointed to the server root like "/my-asset.js".
It is a problem because that means the behaviour is broken in this case.
The problem was present from the setup, it was not possible to fill the
setup since the path to the scripts and CSS weres wrong.

The "asset" helper is now used and resolves the URI.

See: cachethq#3618
nalysius added a commit to nalysius/Cachet that referenced this issue Jun 8, 2019
The `asset()` helper was missing at some places so it was not possible
to install it in an other place than the server's root (/).

The paths have been fixed and now use the `asset()` helper. Also,
The steps process takes care of the current path.

See: cachethq#3618
nalysius added a commit to nalysius/Cachet that referenced this issue Jun 19, 2019
The `asset()` helper was missing at some places so it was not possible
to install it in an other place than the server's root (/).

The paths have been fixed and now use the `asset()` helper. Also,
The steps process takes care of the current path.

See: cachethq#3618
nalysius added a commit to nalysius/Cachet that referenced this issue Jun 19, 2019
Cachet may be installed at the root of its vhost or in a subdirectory,
for example in "/" or under "/status".

The URI we found pointing to some assets were usually not prefixed with
the path, so if Cachet was installed under "/status" the asset
URI pointed to the server root like "/my-asset.js".
It is a problem because that means the behaviour is broken in this case.
The problem was present from the setup, it was not possible to fill the
setup since the path to the scripts and CSS weres wrong.

The "asset" helper is now used and resolves the URI.

See: cachethq#3618
@jbrooksuk
Copy link
Member

This should now be fixed!

@anthosz
Copy link
Author

anthosz commented Jun 24, 2019

Dear @jbrooksuk ,

There is only one problem left concerning ionicons.svg & ionicions.woff called by /dist/css/app.css (dashboard anonymous & logged)

The link to woff/svg in the CSS is url("../../../fonts/ionicons.ttf?v=2.0.1" instead url("/a/b/c/fonts/ionicons.ttf?v=2.0.1"

For the rest, all seems fixed now :)

Thx!

@jbrooksuk
Copy link
Member

I believe @anthonybocci has fixed fonts now?

@nalysius
Copy link
Contributor

@jbrooksuk I didn't touch the fonts. I'll check during the week-end to remember the problem, reproduce it and see if I can fix it. I'll let you know.

@nalysius
Copy link
Contributor

nalysius commented Jul 17, 2019

I just tested now with 2.3 and 2.4 since I didn't know about what version you were talking about, but I have no 404 in my browser. I guess you are talking about 2.4, so @anthosz could you lead me to reproduce the 404? I checked in my browser's console.
@jbrooksuk could you assign me to this issue please? Otherwise that's difficult to find it when I don't remember its number, it's closed and I'm not assignee.

@anthosz
Copy link
Author

anthosz commented Jul 19, 2019

@anthonybocci it's 2.4 (revision c74193e Sat Jul 13 17:31:27 2019 +0100).

So to summarize, you just need to go on the root page (like example.org/subdirectory/sub2/cachet) (anonymous & logged) and the url is not ok for .ttf/.woff :
image

In our case, instead to call these resources on example.org/subdirectory/sub2/cachet/fonts/., these resources are called on example.org/subdirectory/sub2/fonts/. (missing /cachet)

.env:
APP_URL=http://example.org/subdirectory/sub2/cachet
apache conf:
RewriteBase /subdirectory/sub2/cachet

@pavanfhw
Copy link

pavanfhw commented Feb 20, 2023

@anthosz @nalysius @jbrooksuk
I'm having this issue. I'm running on Docker and built using this Dockerfile with version 2.4.
I have APP_URL set to https://mydomain.com/status but I still get 404 on all request to js and css.
I trtied adding RewriteBase /status to /var/www/html/public/.htaccess but no change.

The setup page is exactly like in the example of this issue. What do I have to do to work?

@anthosz
Copy link
Author

anthosz commented Feb 20, 2023

@anthosz @nalysius @jbrooksuk I'm having this issue. I'm running on Docker and built using this Dockerfile with version 2.4. I have APP_URL set to https://mydomain.com/status but I still get 404 on all request to js and css. I trtied adding RewriteBase /status to /var/www/html/public/.htaccess but no change.

The setup page is exactly like in the example of this issue. What do I have to do to work?

This project is not maintained anymore

@pavanfhw
Copy link

pavanfhw commented Feb 20, 2023

I know, but should the issue been fixed in the latest version?

@anthosz
Copy link
Author

anthosz commented Feb 20, 2023

I knwo, but should the issue been fixed in the latest version?

The last version is old of more/less 4 years so.. during this time, laravel/php/composer has been updated so no make sense to use it...

You need to switch to another solution (not found a correct one on our side so switched to commercial solution)

@pavanfhw
Copy link

You are right. Thank you for answering me!

@nalysius
Copy link
Contributor

@anthosz @nalysius @jbrooksuk I'm having this issue. I'm running on Docker and built using this Dockerfile with version 2.4. I have APP_URL set to https://mydomain.com/status but I still get 404 on all request to js and css. I trtied adding RewriteBase /status to /var/www/html/public/.htaccess but no change.

The setup page is exactly like in the example of this issue. What do I have to do to work?

The easiest would be to use a subdomain status.mydomain.com, so no problems with this.
But as said by anthosz, the project has not been maintained for several years, I don't recommend to use it.

The other day I was thinking about creating a status page, way simpler than Cachet, just a Symfony API, a front-end, no JavaScript. An API compatible with Cachet, so the modules would still work. Something easy to maintain and with as few dependencies as possible. I have to think about it, if it's a good idea or not.

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

No branches or pull requests

4 participants