File tree 3 files changed +10
-3
lines changed
3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change
1
+ .git
Original file line number Diff line number Diff line change @@ -35,16 +35,20 @@ const handleResponse = async (response: Response) => {
35
35
}
36
36
} ;
37
37
38
+ const isBrowser = typeof window !== 'undefined' ;
39
+
38
40
export const get = async (
39
41
url : string ,
40
42
params = new URLSearchParams ( ) ,
41
43
opts : { fetch ?: typeof fetch } = { }
42
- ) =>
43
- ( opts . fetch ?? fetch ) ( `${ BASE_URL } ${ url } ?${ params . toString ( ) } ` , {
44
- mode : 'cors' ,
44
+ ) => {
45
+ return ( opts . fetch ?? fetch ) ( `${ BASE_URL } ${ url } ?${ params . toString ( ) } ` , {
46
+ // for server-side rendering, use same origin policy
47
+ mode : isBrowser ? 'cors' : 'same-origin' ,
45
48
credentials : 'include' ,
46
49
redirect : 'follow'
47
50
} ) . then ( handleResponse ) ;
51
+ } ;
48
52
49
53
export const post = async ( url : string , body : any ) =>
50
54
fetch ( `${ BASE_URL } ${ url } ` , {
Original file line number Diff line number Diff line change 1
1
<script context =" module" lang =" ts" >
2
+ export let prerender = false ;
3
+
2
4
import type { Load } from ' @sveltejs/kit' ;
3
5
import { upcoming } from ' $lib/subscriptions' ;
4
6
You can’t perform that action at this time.
0 commit comments