Rocky_Mountain_Vending/.pnpm-store/v10/files/22/a6b71d1c3995317db296c15cee2b1c2460f3d0a53145bf50540546239b4b08157a2fd9822849d4e8d965cc9a443aa89e89787a8f66752dd3fb890f64d5fb54
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

41 lines
1.3 KiB
Text

export const regionRedirectEndpointMiddleware = (config) => {
return (next, context) => async (args) => {
const originalRegion = await config.region();
const regionProviderRef = config.region;
let unlock = () => { };
if (context.__s3RegionRedirect) {
Object.defineProperty(config, "region", {
writable: false,
value: async () => {
return context.__s3RegionRedirect;
},
});
unlock = () => Object.defineProperty(config, "region", {
writable: true,
value: regionProviderRef,
});
}
try {
const result = await next(args);
if (context.__s3RegionRedirect) {
unlock();
const region = await config.region();
if (originalRegion !== region) {
throw new Error("Region was not restored following S3 region redirect.");
}
}
return result;
}
catch (e) {
unlock();
throw e;
}
};
};
export const regionRedirectEndpointMiddlewareOptions = {
tags: ["REGION_REDIRECT", "S3"],
name: "regionRedirectEndpointMiddleware",
override: true,
relation: "before",
toMiddleware: "endpointV2Middleware",
};