With Cloudfront's new functions feature:
function handler (event) { var request = event.request; var headers = request.headers; var authString = "Basic BASE64_OF_USERNAME:PASSWORD"; // If authorization header isn't present or doesn't match expected authString, deny the request if ( typeof headers['authorization'] == 'undefined' || headers['authorization'].value !== authString ) { return { statusCode: 401, statusDescription: 'Unauthorized', headers: { 'www-authenticate': { value: 'Basic' } }, }; } return request; };
And then associate the function with the distribution
EEEEZZZ
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
With Cloudfront's new functions feature:
And then associate the function with the distribution
EEEEZZZ