The same Response object mutated
// Create a response, then setup CORS for it
export async function loader({ request }: LoaderFunctionArgs) {
let data = await getData(request);
let response = json<LoaderData>(data);
return await cors(request, response);
}
// Create response and setup CORS in a single line
export async function loader({ request }: LoaderFunctionArgs) {
let data = await getData(request);
return await cors(request, json<LoaderData>(data));
}
// Setup for any data request
export let handleDataRequest: HandleDataRequestFunction = async (
response,
{ request }
) => {
return await cors(request, response);
};
Setup CORS for a giving Request and Response objects pair using the specified options.
The default options are: