Sharing data between sites


#1

I have created an asset listing in one of our squiz sites, which is presenting the output as json data.
I am then wanting to then use this json data in other sites/globes.

Is there a way squiz can push this data out / way in which I can get the data back in whilst avoiding the usual CORS issues?

I have messed around using the RestAPI, but am running into access issues.

Thank you.


(Nic Hubbard) #2

Other sites in Matrix? Just link this Asset Listing into your other sites so that it will have a URL for those sites as well.


(John gill) #3

My normal approach for “Use a JSON Asset Listing from Site A in Site B” is to create a Remote Content asset in Site B and point it the appropriate URL on Site A. No need to mess around with REST Resource assets. It’s not perfect, because by adding a “proxy” asset you complicate the situation when it comes to caching etc, but it does workaround the CORS issues by allowing you to access it “same origin”.

Alternatively, I haven’t done it myself but my understanding is that it’s possible to use triggers to send the correct CORS headers for specific URLs.

Futurely, there is a SquizMap on the topic of “defining a greater variety of https headers without triggers” at https://squizmap.squiz.net/matrix/5978 , which seems to have some recent activity. With any luck, whatever shakes out of that will make it easier to use the direct CORS approach in the future :crossed_fingers:.


#4

Thanks @JohnGill
The remote content asset might be the way forward. I had tried to implement previously, but am getting the following error message. Something to do with permissions?

"Content cannot be accessed "


(John gill) #5

The real weak point of the Remote Content asset is trying to debug things like this. “Content cannot be accessed” can be a lot of different issues in the HTTP request between Site B and Site A.

I just realised that you’re probably referring to multiple sites on the same Matrix instance, rather than multiple Matrix instances. If that’s true, it would be much simpler to just give the JSON asset listing a Site B URL in addition to the Site A URL.

Normally I avoid multiple URLs, but if the asset isn’t a page then the usual SEO considerations don’t apply.


#6

Hi @JohnGill, this is for separate matrix environments.

  • Trying to compile reporting information, such as number of assets per globe for example.

#7

Resolved using the Rest API.

Had to add Content-type: application/json into the request headers.


#8

For someone else looking at doing something similar, the solution above works…but to a point.
The asset listing pushes out the JSON data as intended, however piping this in via the RestAPI to another environment will only bring through the sites which are live. Sites under construction are not carried through without providing public read access, which obviously isnt a great idea.

Still havent figured out how to apply the required authentication to get the whole report through. When I figure it out, I will update this with the solution mk2.