File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 11import Image from 'next/image'
22import img from './unsplash.jpg'
3+ import logo from './logomark.svg'
34
45const Images = ( ) => (
56 < div >
@@ -11,6 +12,9 @@ const Images = () => (
1112 </ a > { ' ' }
1213 on < a href = "https://unsplash.com/?utm_source=unsplash& utm_medium = referral & utm_content = creditCopyText " > Unsplash</ a >
1314 </ p >
15+ < p >
16+ < Image src = { logo } alt = "netlify logomark" />
17+ </ p >
1418 </ div >
1519)
1620
Original file line number Diff line number Diff line change @@ -39,10 +39,13 @@ const handler = async (event) => {
3939 const quality = parseInt ( q ) || 60
4040
4141 let imageUrl
42+ let isRemoteImage = false
4243 // Relative image
4344 if ( parsedUrl . startsWith ( '/' ) ) {
44- imageUrl = `${ process . env . DEPLOY_URL || `http://${ event . headers . host } ` } ${ parsedUrl } `
45+ const protocol = event . headers [ 'x-nf-connection-proto' ] || event . headers [ 'x-forwarded-proto' ] || 'http'
46+ imageUrl = `${ protocol } ://${ event . headers . host || event . hostname } ${ parsedUrl } `
4547 } else {
48+ isRemoteImage = true
4649 // Remote images need to be in the allowlist
4750 const allowedDomains = process . env . NEXT_IMAGE_ALLOWED_DOMAINS
4851 ? process . env . NEXT_IMAGE_ALLOWED_DOMAINS . split ( ',' ) . map ( ( domain ) => domain . trim ( ) )
@@ -96,7 +99,7 @@ const handler = async (event) => {
9699 return {
97100 statusCode : 302 ,
98101 headers : {
99- Location : imageUrl ,
102+ Location : isRemoteImage ? imageUrl : parsedUrl ,
100103 } ,
101104 }
102105 }
You can’t perform that action at this time.
0 commit comments