Skip to content

Conversation

@JorisOrangeStudio
Copy link
Contributor

This PR modifies the /!/nocache URL in the NoCache JavaScript to utilize URL::prependSiteUrl(), thereby ensuring that it uses to the site’s APP_URL configuration. This aligns with the behavior of other action routes, such as forms and authentication.

Sites running on a subdirectory (e.g., https://domain.com/subsite) now have their NoCache AJAX requests sent to https://domain.com/!/nocache instead of https://domain.com/subsite/!/nocache.

@jasonvarga
Copy link
Member

Sites running on a subdirectory (e.g., domain.com/subsite) now have their NoCache AJAX requests sent to domain.com/!/nocache instead of domain.com/subsite/!/nocache.

They shouldn't have anyway. It was doing a fetch to /!/nocache which would be relative to the domain.

I don't see how it would have ever hit subdirectory/!/nocache. 🤔

@JorisOrangeStudio
Copy link
Contributor Author

They shouldn't have anyway. It was doing a fetch to /!/nocache which would be relative to the domain.

I don't see how it would have ever hit subdirectory/!/nocache. 🤔

The fetch('/!/nocache', ...) resolves against the page's origin https://example.com. So even when browsing https://example.com/subdirectory/some-page, the nocache fetch goes to https://example.com/!/nocache instead of https://example.com/subdirectory/!/nocache. Our install runs at https://example.com/subdirectory/, so the nocache endpoint should be hit at /subdirectory/!/nocache, right?
Happy to provide a working example site via Discord if needed.

@jasonvarga
Copy link
Member

Gotcha, I thought you meant you had a Statamic multisite site configured at a subdirectory, not the entire app.

@jasonvarga jasonvarga changed the title [5.x] Utilize URL facade for nocache URL in JS [5.x] Avoid hardcoded nocache url in js Dec 1, 2025
@jasonvarga jasonvarga merged commit 67ddc59 into statamic:5.x Dec 1, 2025
25 checks passed
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 this pull request may close these issues.

2 participants