File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,19 @@ export function useStripeProvider() {
2525 )
2626 } )
2727
28+ const { apiClient } = useRuntimeConfig ( ) . public
29+ const csrfToken = ref ( )
2830 const stripeInit = async ( stripePulicKey : string ) => {
2931 if ( stripePulicKey === '' ) {
3032 return
3133 }
32-
34+ await $fetch ( `${ apiClient } /pricing` , {
35+ onResponse ( {
36+ response,
37+ } ) {
38+ csrfToken . value = response . headers . get ( 'x-csrf-token' ) ?? ''
39+ } ,
40+ } )
3341 stripe . value = await loadStripe ( stripePulicKey )
3442 }
3543
@@ -45,6 +53,9 @@ export function useStripeProvider() {
4553 {
4654 baseURL : stripeBaseUrl ,
4755 body : JSON . stringify ( { returnURL : window . location . href } ) ,
56+ headers : {
57+ 'x-csrf-token' : csrfToken . value ,
58+ } ,
4859 } ,
4960 )
5061
@@ -69,6 +80,9 @@ export function useStripeProvider() {
6980 priceId,
7081 promotionCode : promoCode ,
7182 } ) ,
83+ headers : {
84+ 'x-csrf-token' : csrfToken . value ,
85+ } ,
7286 } ,
7387 )
7488
You can’t perform that action at this time.
0 commit comments