// On your Squarespace page (e.g., in a Code Block or Custom CSS/JS injection)
window.onload = function() {
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');
const state = urlParams.get('state');
if (code && state) {
// Redirect to your actual backend server to handle the token exchange
window.location.href = `https://your-backend-server.com/process-fhir-auth?code=<span class="math-inline">\{code\}&state\=</span>{state}`;
// OR make an AJAX call if you prefer to keep the user on the Squarespace page
// fetch(`https://your-backend-server.com/process-fhir-auth`, {
// method: 'POST',
// headers: { 'Content-Type': 'application/json' },
// body: JSON.stringify({ code, state })
// })
// .then(response => response.json())
// .then(data => {
// // Handle response from your backend
// })
// .catch(error => console.error('Error:', error));
}
};