feat: update remote patterns to be more permissive
This commit is contained in:
@@ -47,49 +47,13 @@ const config = {
|
|||||||
remotePatterns: (() => {
|
remotePatterns: (() => {
|
||||||
/** @type {Array<{protocol: "http" | "https", hostname: string}>} */
|
/** @type {Array<{protocol: "http" | "https", hostname: string}>} */
|
||||||
const patterns = [
|
const patterns = [
|
||||||
{
|
{ protocol: "https", hostname: "**" },
|
||||||
protocol: "https",
|
|
||||||
hostname:
|
|
||||||
env("S3_FORCE_PATH_STYLE") === "true"
|
|
||||||
? `${env("NEXT_PUBLIC_STORAGE_DOMAIN")}`
|
|
||||||
: `*.${env("NEXT_PUBLIC_STORAGE_DOMAIN")}`,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
protocol: "http",
|
protocol: "http",
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
protocol: "https",
|
|
||||||
hostname: "*.googleusercontent.com",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
protocol: "https",
|
|
||||||
hostname: "cdn.discordapp.com",
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Extract root domain from S3_ENDPOINT and add wildcard pattern
|
|
||||||
const s3Endpoint = env("S3_ENDPOINT");
|
|
||||||
if (s3Endpoint) {
|
|
||||||
try {
|
|
||||||
const url = new URL(s3Endpoint);
|
|
||||||
const hostname = url.hostname;
|
|
||||||
const protocol = url.protocol.replace(":", "");
|
|
||||||
|
|
||||||
// Extract root domain (last 2 parts: e.g. cloudflarestorage.com)
|
|
||||||
const parts = hostname.split(".");
|
|
||||||
if (parts.length >= 2) {
|
|
||||||
const rootDomain = parts.slice(-2).join(".");
|
|
||||||
patterns.push({
|
|
||||||
protocol: protocol === "http" ? "http" : "https",
|
|
||||||
hostname: `*.${rootDomain}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// If S3_ENDPOINT is not a valid URL, ignore it
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return patterns;
|
return patterns;
|
||||||
})(),
|
})(),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user