File tree 3 files changed +21
-2
lines changed
3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
1
import Image from 'next/image'
2
2
import img from './unsplash.jpg'
3
+ import logo from './logomark.svg'
3
4
4
5
const Images = ( ) => (
5
6
< div >
@@ -11,6 +12,9 @@ const Images = () => (
11
12
</ a > { ' ' }
12
13
on < a href = "https://unsplash.com/?utm_source=unsplash& utm_medium = referral & utm_content = creditCopyText " > Unsplash</ a >
13
14
</ p >
15
+ < p >
16
+ < Image src = { logo } alt = "netlify logomark" />
17
+ </ p >
14
18
</ div >
15
19
)
16
20
Original file line number Diff line number Diff line change @@ -39,10 +39,15 @@ const handler = async (event) => {
39
39
const quality = parseInt ( q ) || 60
40
40
41
41
let imageUrl
42
+ let isRemoteImage = false
42
43
// Relative image
43
44
if ( parsedUrl . startsWith ( '/' ) ) {
44
- imageUrl = `${ process . env . DEPLOY_URL || `http://${ event . headers . host } ` } ${ parsedUrl } `
45
+ imageUrl = `${ event . protocol || ( event . headers . scheme && `${ event . headers . scheme } :` ) || 'http:' } //${
46
+ event . headers . host || event . hostname
47
+ } ${ parsedUrl } `
48
+ console . log ( { imageUrl } )
45
49
} else {
50
+ isRemoteImage = true
46
51
// Remote images need to be in the allowlist
47
52
const allowedDomains = process . env . NEXT_IMAGE_ALLOWED_DOMAINS
48
53
? process . env . NEXT_IMAGE_ALLOWED_DOMAINS . split ( ',' ) . map ( ( domain ) => domain . trim ( ) )
@@ -96,7 +101,8 @@ const handler = async (event) => {
96
101
return {
97
102
statusCode : 302 ,
98
103
headers : {
99
- Location : imageUrl ,
104
+ Location : isRemoteImage ? imageUrl : parsedUrl ,
105
+ 'X-Event' : JSON . stringify ( event ) ,
100
106
} ,
101
107
}
102
108
}
You can’t perform that action at this time.
0 commit comments