Skip to content

POST not working with static redirected S3 site

0

Hello,

I've built a static site with redirect in S3. The GET method works and bring the data from target URL. But the POST method does not work and returns the below error. I've also enabled CORS for the bucket (please see below the configuration). Even if CORS is enabled in the 405 response I got headers: Access-Control-Allow-Methods(PUT, POST) together with Allow(GET, HEAD, OPTIONS). The target URL has also CORS enabled.

Could you please specify how to enable POST in this redirect ?

<html>
<head>
	<title>405 Method Not Allowed</title>
</head>
<body>
	<h1>405 Method Not Allowed</h1>
	<ul>
		<li>Code: MethodNotAllowed</li>
		<li>Message: The specified method is not allowed against this resource.</li>
		<li>Method: POST</li>
		<li>ResourceType: OBJECT</li>
		<li>RequestId: 6CKWBHWQ1NDT23BK</li>
		<li>HostId: WOWpQ7TUER6ZrN5TFCd4+eWMLir8bh5cZqXFERixkACtN611XW+IqILMvt45VAb5AQRAo/AlwfM=</li>
	</ul>
	<hr />
</body>
</html>
[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]
1 Answer
1
Accepted Answer

Hello.

Are you trying to send some data to S3 using the POST method?
Or are you trying to send some data via POST from a static site in S3 to another site?

If you are trying to POST some data to S3, I don't think you can do it with the website endpoint of static website hosting.
https://repost.aws/ja/questions/QUfOUh-fQ4TNKBOqQFqCIkaw/cloudfront-s3-static-website-hosting-issues-with-contact-form-submission

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

  • Thank you for your answer,

    To clarify, I try to send some data from localhost Postman to S3 using POST method.

    I've read the link you provided, and notice two types of endpoints to S3: S3 REST endpoint (bucket-name.s3.amazonaws.com), and S3 Static Website endpoint (s3-website-region.amazonaws.com). The REST endpoint is the same as the one where the REST commands are sent to S3 (https://docs.aws.amazon.com/AmazonS3/latest/API/Welcome.html), or is another one ?

    Thank you,
    Mihai ADAM

  • For REAT API "bucket-name.s3.amazonaws.com" should be used.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.