Skip to content

Commit 58cf034

Browse files
committed
temp: add token on frontend
1 parent ba7dbca commit 58cf034

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

frontend/composables/useStripeProvider.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import type {
1212

1313
export function useStripeProvider() {
1414
const { fetch } = useCustomFetch()
15+
const { tokenCsrf } = useCsrfStore()
16+
1517
const { promoCode } = usePromoCode()
1618
const { public: { stripeBaseUrl } } = useRuntimeConfig()
1719

@@ -45,6 +47,9 @@ export function useStripeProvider() {
4547
{
4648
baseURL: stripeBaseUrl,
4749
body: JSON.stringify({ returnURL: window.location.href }),
50+
headers: {
51+
'x-csrf-token': tokenCsrf.value,
52+
},
4853
},
4954
)
5055

@@ -69,6 +74,9 @@ export function useStripeProvider() {
6974
priceId,
7075
promotionCode: promoCode,
7176
}),
77+
headers: {
78+
'x-csrf-token': tokenCsrf.value,
79+
},
7280
},
7381
)
7482

frontend/pages/pricing.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ const scrollToAddons = () => {
2727
const element = document.getElementById('addons')
2828
element?.scrollIntoView({ behavior: 'smooth' })
2929
}
30+
31+
const { setTokenCsrf } = useCsrfStore()
32+
callOnce(async () => await $fetch('https://v2-staging-hoodi-dev.beaconcha.in/api/i/pricing', {
33+
onResponse({
34+
response,
35+
}) {
36+
const token = response.headers.get('x-csrf-token') ?? ''
37+
setTokenCsrf(token)
38+
},
39+
}))
3040
</script>
3141

3242
<template>

0 commit comments

Comments
 (0)