Skip to content

Conversation

AlexTMjugador
Copy link
Member

Overview

While testing the changes from #4343, I noticed that local environment deployments failed to update project view analytics in Clickhouse at the request of a local frontend server, always returning an HTTP 400 error with an invalid page view URL specified! message.

Looking into the cause, I found that the analytics ingestion code relied on a list of allowed origins defined in the CORS_ALLOWED_ORIGINS environment variable for view URL filtering. However, this variable is not defined in any .env template in the repository, nor in any staging or production environment as far as I can tell. It's also not validated during Labrinth startup in the check_env_vars function. The only reason views were counted in production was due to special-case code that allowed subdomains of modrinth.com as origins, an inelegant workaround that is inconsistent with the existing CORS filtering, which already happens at a higher layer and is configured through the ANALYTICS_ALLOWED_ORIGINS variable.

To resolve this, the PR removes the invalid reference to CORS_ALLOWED_ORIGINS, making the filter code use the intended ANALYTICS_ALLOWED_ORIGINS variable instead. This ensures views are counted in all deployments and eliminates recurring request error logs whenever a project is opened in Labrinth under these environments.

@AlexTMjugador AlexTMjugador added bug Something isn't working backend Relates to Modrinth Backend or API labels Sep 6, 2025
@AlexTMjugador AlexTMjugador force-pushed the alex/view-analytics-fix branch from 22dbe3d to 6a23c75 Compare September 6, 2025 16:44
@AlexTMjugador AlexTMjugador added this pull request to the merge queue Sep 10, 2025
Merged via the queue into main with commit 9361acb Sep 10, 2025
3 checks passed
@AlexTMjugador AlexTMjugador deleted the alex/view-analytics-fix branch September 11, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Relates to Modrinth Backend or API bug Something isn't working

Development

Successfully merging this pull request may close these issues.

2 participants