- Newest
- Most votes
- Most comments
hi,
Frontend needs to talk to backend URL, and backend need to allow request only from CloudFront via CORS.
Frontend .evn file
VITE_API_URL=https://your-backend-api-url
FRONTEND_URL=https://djuvfvjpgozm1.cloudfront.net
[ Vite_API_URL needs to point to Beanstalk URL (e.g., https://my-app.us-east-1.elasticbeanstalk.com).]
your backend .eve need to know which origin to allow:
The CloudFront URL that hosts your frontend
FRONTEND_URL=https://djuvfvjpgozm1.cloudfront.net [this CF URL that backend will allow as an origin in CORS configuration]
CORS Configuration:
your Express app CORS is configured properly?
Express app needs to be configured to allow requests from CloudFront URL.
// Get the frontend URL from environment variables const frontendURL = process.env.FRONTEND_URL || 'https://djuvfvjpgozm1.cloudfront.net';
Note: after update <npm run build> and redeploy to CloudFront.
your CloudFront distribution forwards the Origin header to the backend here is the link: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-origin-requests.html?utm_source
Hope it will help Best
answered a year ago
Relevant content
asked 4 years ago
asked 4 years ago
