@@ -5,14 +5,18 @@ import {ExternalLink} from "lucide-react"
55interface ProjectPreviewProps {
66 url : string
77 title : string
8+ renderUrl ?: string
89}
910
10- export async function ProjectPreview ( { url, title} : ProjectPreviewProps ) {
11+ export async function ProjectPreview ( { url, title, renderUrl } : ProjectPreviewProps ) {
1112 let htmlContent = ""
1213 let error = false
1314
15+ // Use renderUrl if provided, otherwise use the regular url
16+ const urlToFetch = renderUrl || url
17+
1418 try {
15- const response = await fetch ( url , {
19+ const response = await fetch ( urlToFetch , {
1620 headers : {
1721 "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" ,
1822 } ,
@@ -46,11 +50,12 @@ export async function ProjectPreview({url, title}: ProjectPreviewProps) {
4650
4751 // Get the base URL (in case of redirects, use the final URL)
4852 const baseUrl = new URL ( response . url )
49- const baseHref = `${ baseUrl . protocol } //${ baseUrl . host } `
53+ // Use the full origin with trailing slash to ensure all resources load correctly
54+ const baseHref = baseUrl . origin + '/'
5055
5156 // Inject base tag, CSP meta tag (blocking all scripts), and no-scroll style in the head
52- const baseTag = `<base href="${ baseHref } / ">`
53- const cspMeta = `<meta http-equiv="Content-Security-Policy" content="default-src 'self' ; script-src 'none'; style-src 'self' 'unsafe-inline' https: ; img-src * data: blob:; font-src * data:; connect-src * data: blob:;">`
57+ const baseTag = `<base href="${ baseHref } ">`
58+ const cspMeta = `<meta http-equiv="Content-Security-Policy" content="default-src * ; script-src 'none'; style-src * 'unsafe-inline'; img-src * data: blob:; font-src * data:; connect-src * data: blob:;">`
5459 const noScrollStyle = `<style>html, body { overflow: hidden !important; }</style>`
5560
5661 if ( html . includes ( '<head>' ) ) {
@@ -70,7 +75,7 @@ export async function ProjectPreview({url, title}: ProjectPreviewProps) {
7075 }
7176
7277 return (
73- < div className = "relative aspect-video w-full overflow-hidden bg-muted rounded-lg border border-border" >
78+ < div className = "relative w-full h-48 overflow-hidden bg-muted rounded-lg border border-border" >
7479 { error ? (
7580 < div className = "flex h-full items-center justify-center text-muted-foreground p-4" >
7681 < div className = "text-center" >
0 commit comments