Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Verifying domain for Facebook Graph API in self-hosted Sanity studio

31 replies
Last updated: Jun 10, 2022
hello everyone, i need to verify my domain to use the facebook graph api as the doc says https://www.facebook.com/business/help/321167023127050 . I need to either add a file at the root of my projet to be publicly visible or add a meta tag or add a txt record.I didnt use the sanity ui i have no idea what i can customize other than the schemas and some small stuff.
How can i achieve this ? thank you
Jun 10, 2022, 8:10 AM
Do you want to do that for your website or your self-hosted studio?
Jun 10, 2022, 8:11 AM
i need it for the self hosted studio since i use a custom publishing action button to publish from the sanity studio to a facebook page
Jun 10, 2022, 8:13 AM
What is the URL of your Studio? Is it on *.sanity.studio or on your own domain?
Jun 10, 2022, 8:20 AM
its on sanity.studio
Jun 10, 2022, 8:21 AM
Alright. So a TXT record is not going to be possible, that’s for sure, since you don’t host the studio yourself. Same for the file, same reason.
Jun 10, 2022, 8:26 AM
Your only chance is a meta tag. If it can be added dynamically with JavaScript — which I doubt — then you could inject it yourself, but I’m pretty sure it needs to be there on the server response.
Jun 10, 2022, 8:26 AM
What does your custom action does exactly?
Jun 10, 2022, 8:26 AM
it’s an http post method with a token and a payload
Jun 10, 2022, 8:27 AM
wich use sanity fields to populate the payload
Jun 10, 2022, 8:27 AM
And this request goes to Facebook servers?
Jun 10, 2022, 8:27 AM
Jun 10, 2022, 8:28 AM
I don’t think you’ll be able to verify your Studio since it’s not your domain. I guess you could self-host the Studio wherever you want, but that’s a pain. Is there a way around it? Can’t you pass a specific header to your request or something?
Jun 10, 2022, 8:28 AM
it says i need to set ownership_permissions: { can_customize_link_posts: true,
},
Jun 10, 2022, 8:30 AM
but it doesnt work and as i went further for informations i saw that the new requirement isa veryfied domain
Jun 10, 2022, 8:30 AM
Another option is to do a POST request to an API route on your own site (which you host and can verify), and then do the Facebook request from there.
Jun 10, 2022, 8:31 AM
sure
Jun 10, 2022, 8:32 AM
but i lose the the ability to use sanity to use the action button
Jun 10, 2022, 8:33 AM
How so?
Jun 10, 2022, 8:34 AM
oh yeah
Jun 10, 2022, 8:35 AM
i misunderstood
Jun 10, 2022, 8:35 AM
yeah i think i can do that
Jun 10, 2022, 8:36 AM
Alright. 😊
Jun 10, 2022, 8:37 AM
Do you use Next.js or something for your site?
Jun 10, 2022, 8:37 AM
I use nextjs
Jun 10, 2022, 8:48 AM
Pretty convenient then! Make your action ping a specific API route on your Next.js site, and have that server-side API handler ping Facebook.
Jun 10, 2022, 8:49 AM
Yeah !
Jun 10, 2022, 8:50 AM
I guess the request will take longer but It should work
Jun 10, 2022, 8:51 AM
If it’s done only on publication, it should be marginal. It’s also not a critical request as far as I understand.
Jun 10, 2022, 8:51 AM
Ok I'll try this implementation and get back to you
Jun 10, 2022, 8:58 AM
Thank you very much anyway 😃
Jun 10, 2022, 8:59 AM
Cheers!
Jun 10, 2022, 9:00 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?