analytics
analytics copied to clipboard
Logging plausible event results in CORS error
Past Issues Searched
- [X] I have searched open and closed issues to make sure that the bug has not yet been reported
Issue is a Bug Report
- [X] This is a bug report and not a feature request, nor asking for self-hosted support
Using official Plausible Cloud hosting or self-hosting?
Plausible Cloud from plausible.io
Describe the bug
For some reason a plausible event we send is throwing a CORS error on some pages. We're not entirely sure what could be the issue because the tracking event is reused in two different pages. It works on one page, but it doesn't work on the other.
The payload of the successful event looks like:
{
"name": "View tomogram",
"domain": "cryoetdataportal.czscience.com",
"url": "https://cryoetdataportal.czscience.com/datasets/10002",
"props": {
"datasetId": 10002,
"organism": "Homo sapiens",
"runId": 623,
"tomogramId": 11134,
"type": "dataset"
}
}
The payload of the event with the CORS error looks like:
{
"name": "View tomogram",
"domain": "cryoetdataportal.czscience.com",
"url": "https://cryoetdataportal.czscience.com/runs/623",
"props": {
"datasetId": 10002,
"organism": "Homo sapiens",
"runId": 623,
"tomogramId": 11134,
"type": "run"
}
}
Expected behavior
It should log the event on both pages and not throw a CORS error.
Screenshots
Environment
- OS: MacOS 14.3
- Browser: Google Chrome
- Browser Version: 121.0.6167.160
I have reproduced the issue and will get back to you.
Hi @codemonkey800
I think the problem originates from this package: https://www.npmjs.com/package/axios-cache-interceptor?activeTab=readme
Please see https://github.com/arthurfiorette/axios-cache-interceptor/blob/ad69e6d6e491cfa5fe2cb542bc90fd205fc823e3/docs/src/config/request-specifics.md#cachecachetakeover
in particular this bit:
Please try the fallback suggested and see if the OPTIONS XHR requests are handled then.
FWIW the problem occurs only for that button:
and not that one:
Even though both trigger a new tab link. That should help you figure out the difference
closing this now but feel free to contact our support if you have any further questions
@metmarkosaric i am struggling with the same issue. What exactly is meant with the fallback?
i am using Plausible with vercel. Does that look like the correct setting?
//vercel.json
{
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=0, s-maxage=86400, stale-while-revalidate=59"
},
{
"key": "Access-Control-Allow-Headers",
"value": "Cache-Control, Pragma, Expires"
}
]
}
]
}