#✅ - AWS Amplify 301 error

28 messages · Page 1 of 1 (latest)

tame oak
#

@willow wolf 👋 , have you setup any redirects associated to the custom domain within the next-config.js file or in your app logic such as middleware etc.?

willow wolf
#

So i'm guessing i didn't

#

I did just notice this code tho:
layout.tsx uses this
export const metadata: Metadata = {
metadataBase: new URL(ENV.NEXT_PUBLIC_WEBSITE_URL),

Which is imported from constants.ts

export const ENV = {
NEXT_PUBLIC_WEBSITE_URL: process.env.NEXT_PUBLIC_WEBSITE_URL || 'http://localhost:3000',
NODE_ENV: process.env.NODE_ENV || 'development'
}

Maybe this could be the problem?

tame oak
#

Yeah it seems unlikely to be the cause since the amplifyapp.com subdomain is resolving as expected. Do you have any kind of redirects or forwarding setup with CloudFlare?

willow wolf
#

Not that I know of

#

Is this what you are looking for?

tame oak
willow wolf
#

I have 0 rules defined

tame oak
#

Got it, thanks for confirming. I am investigating into this further.

willow wolf
willow wolf
tame oak
#

This is good to know, once you transferred the domain to cloudflare was the domain resolving as expected (before it was connected to the app)?

willow wolf
#

Yes it worked fine before connecting it to aws

willow wolf
#

it is weird tho. My friend did the exact same and it is working for him with proxy enabled

tame oak
#

Ah okay, i see the custom domain is now resolving. What does this specific proxy setting do?

willow wolf
#

I'll try to figure out a fix. Thanks for the help tho

tame oak
#

It seems when you proxy a CNAME DNS record, the traffic will resolve to Cloudflare's IPs, allowing Cloudflare to optimize, cache, and protect the requests.

willow wolf
#

But now that the proxy is disabled. I have higher chances of getting ddosed etc.

#

i'm using aws free tier, is there anyway i can define a max budget. So when the requests go over the amount the free tier has I don't go broke

tame oak
tame oak
#

Lastly, Amplify Hosting provides a managed infrastructure to host static and dynamic web apps. The resources associated with the Amplify apps such as CloudFront distribution, S3 bucket etc. are managed by the service. CloudFront distributions by default have AWS shield standard enabled which protects against DDoS attacks: https://docs.aws.amazon.com/waf/latest/developerguide/ddos-standard-summary.html.

rain bearBOT
#

✅ - AWS Amplify 301 error