This distribution is not configured to allow the HTTP request

40,767

Solution 1

What the error is trying to tell you is that you cannot use POST. Going to guess that cacheable means GET in this context. You need to go ahead and configure cloud front to allow "upload requests" like POST, PUT, etc. IN this case the request will go to the origin that Cloudfront uses.

Aws docs: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating.html

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating-console.html

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html

Look for Allowed HTTP Methods in last link.

Solution 2

This error happens because CloudFront isn't configured to accept an HTTP request it's being sent (like POST or PATCH).

To fix it, change your CloudFront distributions settings to accept all HTTP methods.

To do that, click on the Behaviors tab of your CloudFront distribution, select the default behavior, click Edit, change the Allowed HTTP Methods to GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE, then click Yes, Edit in the bottom right to save your changes.

Change Allowed HTTP Methods in a CloudFront distribution

It may take several minutes for your CloudFront distribution to propagate the changes.

Share:
40,767
Info at Layoverbox
Author by

Info at Layoverbox

Updated on September 17, 2020

Comments

  • Info at Layoverbox
    Info at Layoverbox over 3 years
    This distribution is not configured to allow the HTTP request method that was used for this request. The distribution supports only cachable requests. 
    

    I have configure the website to only accept https on amazon cloudfront. In a nutshell, you have a php login form, and upon successful login it redirects the user as follow:

     if(isset($_POST['login'])){
    
    [...]
            echo "<script>window.open('coursePayment.php?crs_id=$crs_id','_self')</script>";
    

    below is the form:

     <form style="margin-top:-20px" method='post' action='' class='form-horizontal' role='form'>
           <input type="hidden" id="couponCodeLogin" name="couponCodeLogin">
            <input type="hidden" id="couponCodeLoginAmount" name="couponCodeLoginAmount">
    <br><br>
     <div class="group">      
                <input type='text' class='form-control' name='email' required>
          <span class="highlight"></span>
          <span class="bar"></span>
          <label>Email</label>
        </div>
    
        <div class="group">      
                <input type='password' class='form-control' name='pass' required>
          <span class="highlight"></span>
          <span class="bar"></span>
          <label>Password</label>
        </div>
    
    
                <h5 style="color:#FF6400; cursor:context-menu; margin-top:0px" class="displayForgotPassword">Forgot your password? Click here to retrieve it.</h5><br>
                <input type='submit' id='moreInfoButton' name='login' value='Continue' class='btn btn-danger'>                               
              </form> 
    
  • Mircea
    Mircea about 8 years
    updated answer with links to doc that walk though how you do this in the AWS console
  • Irina
    Irina about 3 years
    doesn't work for me. still the distribution supports only cachable requests.