skip to Main Content

I’ve got a problem with NextJS app. When I try to upload a file from localhost it works very well. The problem appears when I want to upload remotely. I host my app at Github Pages and when I what to do it I got 405 POST Error
enter image description here

I’ve checked the CORS

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST",
            "GET",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [
            "ETag"
        ]
    }
]

and bucket policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::xxx",
                "arn:aws:s3:::xxx/*"
            ]
        }
    ]
}

2

Answers


  1. Chosen as BEST ANSWER

    I'm not sure but I found that the API request to Github pages is not allowed. That's why I've got 405 when I try to hit the https://example.com/api/awsConfit. Can anyone confirm?


  2. On Localhost it works with the same code and the same file? Maybe try uploading with postman to make sure it’s working. My guess is that something with content-type is wrong (I had this issue in the past´)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search