Skip to content

Instantly share code, notes, and snippets.

@EionRobb
Created April 11, 2024 09:32
Show Gist options
  • Save EionRobb/bb136a09dacac8b6f775ac90d68f4ce5 to your computer and use it in GitHub Desktop.
Save EionRobb/bb136a09dacac8b6f775ac90d68f4ce5 to your computer and use it in GitHub Desktop.
AWS Lambda@Edge script for CloudFront to replace square brackets in inertiajs when using laravel-vapor
'use strict';
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
const headers = request.headers;
headers['x-forwarded-host'] = [{
'key': 'X-Forwarded-Host',
'value': headers['host'][0].value,
}];
request.uri = request.uri.replace(/\[/g, '%5B').replace(/\]/g, '%5D');
request.querystring = request.querystring.replace(/\[/g, '%5B').replace(/\]/g, '%5D');
callback(null, request);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment