File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -124,8 +124,13 @@ function PlainImage(imageProps) {
124
124
justify = "center"
125
125
style = { { display : 'flex' } } >
126
126
{ /*eslint-disable-next-line jsx-a11y/alt-text*/ }
127
- < img style = { { maxWidth : '100%' } } src = { imageUrl ( { src} ) } { ...props } />
128
- { props . isRss ? < br /> : null }
127
+ < img
128
+ style = { { maxWidth : '100%' } }
129
+ // Don't proxy image if it's served on an RSS feed to avoid CORs errors
130
+ src = { isRss ? src : imageUrl ( { src} ) }
131
+ { ...props }
132
+ />
133
+ { isRss ? < br /> : null }
129
134
{ props . title ? (
130
135
< Text
131
136
style = { { display : 'block' } }
@@ -134,7 +139,7 @@ function PlainImage(imageProps) {
134
139
weight = { 300 }
135
140
color = "dark-1"
136
141
textAlign = "center" >
137
- { props . isRss ? < em > { props . title } </ em > : props . title }
142
+ { isRss ? < em > { props . title } </ em > : props . title }
138
143
</ Text >
139
144
) : null }
140
145
</ Box >
@@ -147,7 +152,7 @@ function isGif(src: string) {
147
152
}
148
153
149
154
function Image ( props ) {
150
- if ( props . src && isGif ( props . src ) ) {
155
+ if ( props . src && isGif ( props . src ) && ! props . isRss ) {
151
156
return (
152
157
< Box margin = { { vertical : 'medium' } } >
153
158
< GifPlayer style = { { maxWidth : '100%' } } src = { props . src } />
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const imageUrl = ({
12
12
} ) : ?string => {
13
13
const basePath = useBasePath ( ) ;
14
14
if ( src ) {
15
- return `${ basePath } /api/image/${
15
+ return `${ basePath || '' } /api/image/${
16
16
firstFrame ? 'firstFrame/' : ''
17
17
} ${ base64Encode ( src ) } `;
18
18
}
Original file line number Diff line number Diff line change
1
+ // @flow
2
+
1
3
import { useRouter } from 'next/router' ;
2
4
3
- export default function useBasePath ( ) {
5
+ export default function useBasePath ( ) : string {
4
6
try {
5
7
const router = useRouter ( ) ;
6
8
if ( router ) {
7
- return router . basePath ;
9
+ return router . basePath || '' ;
10
+ } else {
11
+ return process . env . BASE_PATH || '' ;
8
12
}
9
13
} catch ( _e ) {
10
14
return process . env . BASE_PATH || '' ;
You can’t perform that action at this time.
0 commit comments