Fix local project thumbnails

This commit is contained in:
Formsmith
2026-06-15 12:31:22 +03:00
parent 29a8d5adab
commit 5d9d14c714
2 changed files with 11 additions and 4 deletions
@@ -33,7 +33,7 @@ function isLocalSameOriginRequest(request: Request) {
if (origin) { if (origin) {
try { try {
const originUrl = new URL(origin); const originUrl = new URL(origin);
if (originUrl.origin !== requestUrl.origin || !LOCAL_HOSTS.has(originUrl.hostname)) { if (!LOCAL_HOSTS.has(originUrl.hostname) || originUrl.port !== requestUrl.port || originUrl.protocol !== requestUrl.protocol) {
return false; return false;
} }
} catch { } catch {
@@ -42,7 +42,7 @@ function isLocalSameOriginRequest(request: Request) {
} }
const fetchSite = request.headers.get("sec-fetch-site"); const fetchSite = request.headers.get("sec-fetch-site");
return !fetchSite || fetchSite === "same-origin" || fetchSite === "none"; return !fetchSite || fetchSite === "same-origin" || fetchSite === "same-site" || fetchSite === "none";
} }
function decodedBase64ByteLength(value: string) { function decodedBase64ByteLength(value: string) {
+9 -2
View File
@@ -879,10 +879,17 @@ function Dashboard({
} }
function ProjectPreview({ accent, thumbnailUrl }: { accent: DashboardProject["accent"]; thumbnailUrl?: string | null }) { function ProjectPreview({ accent, thumbnailUrl }: { accent: DashboardProject["accent"]; thumbnailUrl?: string | null }) {
const [failedThumbnailUrl, setFailedThumbnailUrl] = useState<string | null>(null);
const showThumbnail = Boolean(thumbnailUrl && thumbnailUrl !== failedThumbnailUrl);
useEffect(() => {
setFailedThumbnailUrl(null);
}, [thumbnailUrl]);
return ( return (
<span className={`project-preview accent-${accent}`} aria-hidden="true"> <span className={`project-preview accent-${accent}`} aria-hidden="true">
{thumbnailUrl ? ( {showThumbnail ? (
<img className="project-thumbnail-image" src={thumbnailUrl} alt="" /> <img className="project-thumbnail-image" src={thumbnailUrl ?? ""} alt="" onError={() => setFailedThumbnailUrl(thumbnailUrl ?? null)} />
) : ( ) : (
<> <>
<span className="preview-grid" /> <span className="preview-grid" />