I am having the same error with this code
<!--
templateType: “section”
label: “Multi-row content”
isAvailableForNewContent: true
-->
{% dnd_section %}
{% dnd_module path=‘@hubspot/rich_text’ %}
{% module_attribute “html” %}
<div class=“newsletter”>
<div class=“container px-5 w-75”>
<div class=“row py-5”>
<div class=“col-12 col-md-6”>
<h3 class=“fw-bold”>
Subscribe to my newsletter</h3>
<h5 class=“fs-6”>Subscribe to my newsletter, with thoughts on life, identity, making things and more.</h5>
</div>
<div class=“col-12 col-md-6 d-flex justify-content-md-end align-items-start”>
<form id=“newsletter” class=“w-100 w-md-auto”>
<input type=“text” class=“form-control mb-3 py-2” name=“firstName” placeholder=“First Name” required>
<input type=“email” class=“form-control mb-3 py-2” name=“email” placeholder=“Email address” required>
<button type=“submit” class=“btn btn-primary w-100 py-3”>Subscribe</button>
</form>
</div>
</div>
</div>
</div>
<script>
const url = ‘http://144585255.hs-sites-eu1.com/’;
const apiKey = ‘CiRldTEtMDg5YS1kYzI4LTRlNDktYjE1Ni01MWQ5N2IxODRhOGYQp-T4RBjYyNwfKhkABeaRgmYgcKaY6G_KnGDnM3HmvwmZv6eESgNldTE’;
const form = document.getElementById(‘newsletter’);
form.addEventListener(‘submit’, handleSubmit);
async function handleSubmit(event) {
event.preventDefault();
const formData = new FormData(form);
const data = Object.fromEntries(formData);
try {
const response = await fetch(url, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’: `Bearer ${apiKey}`
},
body: JSON.stringify(data)
});
if(!response.ok) {
throw new Error(‘Request failed’);
}
alert(‘Subscription successful!’);
form.reset();
} catch (error) {
alert(‘Subscription failed. Please try again.’);
}
}
</script>
{% end_module_attribute %}
{% end_dnd_module %}
{% end_dnd_section %}
Access to fetch at ‘https://144585255.hs-sites-eu1.com/’ from origin ‘https://144585255.hubspotpreview-eu1.com’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.