sst / ion

SST v3
https://sst.dev
MIT License
2k stars 234 forks source link

Domain Redirect using Cloudflare #286

Open dev2xl opened 5 months ago

dev2xl commented 5 months ago

For a NextJS website hosted in AWS, and with CloudFlare DNS, if we setup a redirect from www to root domain, ion will create another cloud front distribution to handle the redirect with the code 301 Moved Permanently.

Why not do this at DNS level with a Page Rule for example in Cloudflare?

Why not use the code 308 Permanent Redirect? 301 will change POST to GET. 308 will not do this, I think is more appropriate.

Good work thanks!

fwang commented 5 months ago

Hi @dev2xl, the sst.aws.Nextjs component aims to use AWS only services. And afaik using an S3 bucket + Cloudfront distribution to achieve the redirect is unfortunately the best setup on AWS.

I agree Page Rule makes more sense in ur case. I'd suggest not configure redirect on the Nextjs component. And use the Cloudflare provider to create the page rule.

Let me know if that makes sense.

dev2xl commented 5 months ago

@fwang Yes although can we create page rules from ion? This will help to rely only on ion to setup the infrastructure instead of manually creating the page rules on cloudflare.