Hi @hotify ,
Thanks for reaching out to the community. We are MooseDesk, a comprehensive Live Chat, FAQ & Helpdesk App designed to elevate your customer support experience.
Hello! I understand that you’re trying to set up an external test to ensure your contact form is always working. I have some suggestions to help you better understand the issue and why your bash script isn’t working as expected:
1 - First, try testing the form directly on the website:
- Go to https://calmbuddhi.com.au/pages/contact-us
- Open the Developer Console (F12 or Ctrl+Shift+I)
- Run the following JavaScript script:
fetch('https://calmbuddhi.com.au/contact#ContactForm', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
'form_type': 'contact',
'utf8': '✓',
'contact[Name]': 'Test Name',
'contact[email]': 'test@example.com',
'contact[Message]': 'This is a test message'
})
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
You’ll see a successful submit request in the Network tab.
3 - Now, try running the same script on a different website (not https://calmbuddhi.com.au). You’ll see a CORS error with status code 304 in the Network tab.
4 - This is why you can’t use a bash script to test this form externally. Your website has CORS security measures in place that prevent requests from other domains.
To address this issue, you have several options:
- If you have server access, you could configure it to allow CORS from your domain. However, this may pose security risks.
- Create a separate API endpoint on your server to check the status of the contact form. This endpoint could perform internal checks and return results without encountering CORS issues.
- Use a third-party website testing service capable of simulating user interactions.
- If you still want to use a bash script, you could consider using a proxy server to bypass CORS, but this is not recommended for security reasons.
In conclusion, the inability to use a bash script to test the form externally is due to CORS security measures, not an error in your script. I recommend considering safer alternative methods to test the availability of your contact form.
If this is helpful for you, please let me know by giving MooseDesk a ‘LIKE’. If your question is answered please mark this as 'SOLUTION’.
Thank you for reading. Wish you a nice day ahead!