When we point our domain to CloudFront that proxies requests to our server, we cannot log in to admin anymore, when we type email and password, then click the submit button, it first seems like log-in was successful, then it redirects back to the login page. The only error shown in the console is 401 for the following pages:
/information
/permissions
/me
When we make the domain point directly to our server, we then can log in with no issues.
In all cases, we use Nginx which passes requests to the actual Strapi server through proxy_pass
.
Are there any settings we need to tweak on Strapi? Or are there any headers/settings that need to be added to the CDN service?
Strapi is almost vanilla, other than the URL, models, and db settings, there aren't any actual customizations.
Any suggestions?
I had the same issue and I solved it by modifying the headers forwarding policy in Cloud Front:
Behaviors
and click editCache key and origin requests
sectionCache policy and origin request policy (recommended)
Cache policy
choose CachingDIsabled
(it is managed one)Origin request policy - optional
click on Create origin request policy
to create a custom oneOrigin request policy - optional
and choose the newly created policyObviously, Cloud Front is not including all headers from the origin request which is causing the issue. I hope this solves your problem also.