Closed lilouartz closed 3 months ago
Not a clue. Tried everything. Would be really handy to have this in the documentation.
Unfortunately, a dynamic param $format
must be the entire URL segment, not just a part of it. This is a limitation of React Router.
So if you need to be able to handle any type of file extension, you'll need to do something like this:
// routes/supplements.$product.images.$filename
export async function loader({ params }: LoaderFunctionArgs) {
const { filename } = params
if (!/^supplement-facts\.(webp|avif)$/.test(filename)) {
throw new Response('Not Found', { status: 404 })
}
// return image file as a response
}
ah this explains it! maybe worth adding a callout to the docs because I've spent like two hours experimenting with this haha
Thank you for the response
Both of these should be valid URLs:
I tried:
None of the above work.