Cross Domain issue with Matomo Cloud


(Sven Anker) #1

I am trying to implement Matomo in a web application using the Matomo Cloud Platform. I am using the following plugin: GitHub - matomo-org/matomo-nodejs-tracker: A Node.js wrapper for the Matomo (Piwik) tracking HTTP API .

Every time i send a request to Matomo, i get an error message saying it has Cross-Domain issues:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:7001' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Problem is, i can’t find any documentation or forum post on how to set this up on the cloud platform. I already tried adding url’s to my website (the definition in matomo), but this doesn’t seem to resolve the issue.

Anyone that can help me out here?

Greetings,
Sven


(Lukas Winkler) #2

Hi,

If you want to use the Matomo-NodeJS-Tracker browser-side (even though it is really only intended for NodeJS), the Matomo server needs to send the correct CORS header.

If you are using the InnoCraft Cloud, just contact the support at support at innocraft.cloud, tell them the domain they should add to the CORS header and they’ll set it up for you.

Greetings,

Lukas


(Sven Anker) #3

Thanks for the quick reply! I’ll send an email to the support team :).

Do you have any plugins that are recommended for use in the browser? Or are there no front-end pugins at all?

Greetings,
Sven


(Lukas Winkler) #4

Hi,

It depends on what kind of API you need. If you want to track data and send it to Matomo (so the tracking API), the normal Javascript Tracking code/Client should be what you need.
See also: Single-Page Application Tracking: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

If you want to access the Reporting API, probably direct HTTP requests with the library of your choice are the easiest way. After all the above library just wraps a dictionary to the get parameters.