1

I want to host a serverless contact page on Amazon Cloudfront.

I've followed this tutorial to the tee: Processing a Contact Form Using AWS Cloudfront...

There are many steps, but the most important things that I would like to highlight that I have done correctly:

  • I have set the AWS S3 bucket to public, and given public read access
  • My Cloudfront behavior allows the POST method (which I use in my HTML contact-form and corresponding js)
  • My Lambda function and my API Gateway send an e-mail to me (so I know that is working!)

Still, when I press submit on my actual website, I get this error:

This XML file does not appear to have any style information associated with it.

This XML file does not appear to have any style information associated with it.

Could anyone please suggest to me where I might be going wrong? The website contact form is here.

James Z
  • 12,209
  • 10
  • 24
  • 44
chris
  • 11
  • 3

1 Answers1

0

Under the assumption this is a website endpoint the following appears in the documentation.

Requests supported: Supports only GET and HEAD requests on objects

It looks as though this is not supported for static websites and instead will need to be worked around.

Chris Williams
  • 32,215
  • 4
  • 30
  • 68
  • Hi, thank you for the response Chris! Like I said in my second bullet, I had already addressed this so I know it's not the problem :( Thank you though, it was a good possibility to troubleshoot. – chris Jul 26 '20 at 13:54
  • It looks like this was changed in 2013, so it should accept POST now: https://aws.amazon.com/about-aws/whats-new/2013/10/15/amazon-cloudfront-now-supports-put-post-and-other-http-methods/#:~:text=We%20are%20excited%20to%20announce,%2C%20DELETE%2C%20OPTIONS%20and%20PATCH. – chris Jul 26 '20 at 14:54
  • That links for CloudFront, it’s the S3 bucket returning the error. You can reproduce this by calling the S3 website endpoint :) – Chris Williams Jul 26 '20 at 15:07
  • Ahhh, but I am using a REST API endpoint using API Gateway – chris Jul 26 '20 at 15:14
  • The error message that’s returned in the screenshot is an S3 error. You can tell as the ResourceType is object :) – Chris Williams Jul 26 '20 at 15:18
  • The document you linked to https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html#WebsiteRestEndpointDiff shows that if it's an XML-formatted error response, which mine is, then it is a REST endpoint error. I am probably missing something, and appreciate your help! What do you think a work-around would be? – chris Jul 26 '20 at 15:24
  • You could use an AJAX response to try and post directly to API Gateway rather than posting to what might resolve to an S3 object. You should give that a test first generating a post request using postman (or similar tool) to ensure it works – Chris Williams Jul 26 '20 at 15:28