Use base64 library to encode basic auth 🤦
Buffer being not enabled on Vercel Edge Functions
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
"@sveltejs/kit": "^1.0.0-next.484",
|
"@sveltejs/kit": "^1.0.0-next.484",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
||||||
"@typescript-eslint/parser": "^5.37.0",
|
"@typescript-eslint/parser": "^5.37.0",
|
||||||
|
"base-64": "^1.0.0",
|
||||||
"browserslist": "^4.21.4",
|
"browserslist": "^4.21.4",
|
||||||
"cssnano": "^5.1.13",
|
"cssnano": "^5.1.13",
|
||||||
"eslint": "^8.23.1",
|
"eslint": "^8.23.1",
|
||||||
|
|||||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@@ -8,6 +8,7 @@ specifiers:
|
|||||||
'@sveltejs/kit': ^1.0.0-next.484
|
'@sveltejs/kit': ^1.0.0-next.484
|
||||||
'@typescript-eslint/eslint-plugin': ^5.37.0
|
'@typescript-eslint/eslint-plugin': ^5.37.0
|
||||||
'@typescript-eslint/parser': ^5.37.0
|
'@typescript-eslint/parser': ^5.37.0
|
||||||
|
base-64: ^1.0.0
|
||||||
browserslist: ^4.21.4
|
browserslist: ^4.21.4
|
||||||
cssnano: ^5.1.13
|
cssnano: ^5.1.13
|
||||||
dayjs: ^1.11.5
|
dayjs: ^1.11.5
|
||||||
@@ -51,6 +52,7 @@ devDependencies:
|
|||||||
'@sveltejs/kit': 1.0.0-next.484_svelte@3.50.1+vite@3.1.2
|
'@sveltejs/kit': 1.0.0-next.484_svelte@3.50.1+vite@3.1.2
|
||||||
'@typescript-eslint/eslint-plugin': 5.37.0_22c5fnooleyfkzrkkgdmel5kmi
|
'@typescript-eslint/eslint-plugin': 5.37.0_22c5fnooleyfkzrkkgdmel5kmi
|
||||||
'@typescript-eslint/parser': 5.37.0_irgkl5vooow2ydyo6aokmferha
|
'@typescript-eslint/parser': 5.37.0_irgkl5vooow2ydyo6aokmferha
|
||||||
|
base-64: 1.0.0
|
||||||
browserslist: 4.21.4
|
browserslist: 4.21.4
|
||||||
cssnano: 5.1.13_postcss@8.4.16
|
cssnano: 5.1.13_postcss@8.4.16
|
||||||
eslint: 8.23.1
|
eslint: 8.23.1
|
||||||
@@ -792,6 +794,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/base-64/1.0.0:
|
||||||
|
resolution: {integrity: sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/binary-extensions/2.2.0:
|
/binary-extensions/2.2.0:
|
||||||
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
|
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
|
import base64 from 'base-64'
|
||||||
import { fetchAPI } from '$utils/api'
|
import { fetchAPI } from '$utils/api'
|
||||||
import { PUBLIC_SWELL_STORE_ID } from '$env/static/public'
|
import { PUBLIC_SWELL_STORE_ID } from '$env/static/public'
|
||||||
import { SWELL_API_TOKEN, SWELL_API_ENDPOINT } from '$env/static/private'
|
import { SWELL_API_TOKEN, SWELL_API_ENDPOINT } from '$env/static/private'
|
||||||
@@ -58,7 +59,7 @@ export const load: PageServerLoad = async () => {
|
|||||||
*/
|
*/
|
||||||
const shopProductsRes: any = await fetch(`${SWELL_API_ENDPOINT}/products`, {
|
const shopProductsRes: any = await fetch(`${SWELL_API_ENDPOINT}/products`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${Buffer.from(`${PUBLIC_SWELL_STORE_ID}:${SWELL_API_TOKEN}`).toString('base64')}`
|
Authorization: `Basic ${base64.encode(`${PUBLIC_SWELL_STORE_ID}:${SWELL_API_TOKEN}`)}`
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const shopProducts = await shopProductsRes.json()
|
const shopProducts = await shopProductsRes.json()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
|
import base64 from 'base-64'
|
||||||
import { fetchAPI } from '$utils/api'
|
import { fetchAPI } from '$utils/api'
|
||||||
import { getRandomItem } from '$utils/functions'
|
import { getRandomItem } from '$utils/functions'
|
||||||
import { PUBLIC_SWELL_STORE_ID } from '$env/static/public'
|
import { PUBLIC_SWELL_STORE_ID } from '$env/static/public'
|
||||||
@@ -42,7 +43,7 @@ export const load: PageServerLoad = async ({}) => {
|
|||||||
// Fetch Swell API for product
|
// Fetch Swell API for product
|
||||||
const shopProductRes: any = await fetch(`${SWELL_API_ENDPOINT}/products/${randomPoster.product_id}`, {
|
const shopProductRes: any = await fetch(`${SWELL_API_ENDPOINT}/products/${randomPoster.product_id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${Buffer.from(`${PUBLIC_SWELL_STORE_ID}:${SWELL_API_TOKEN}`).toString('base64')}`
|
Authorization: `Basic ${base64.encode(`${PUBLIC_SWELL_STORE_ID}:${SWELL_API_TOKEN}`)}`
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const shopProduct = await shopProductRes.json()
|
const shopProduct = await shopProductRes.json()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
|
import base64 from 'base-64'
|
||||||
import { fetchAPI } from '$utils/api'
|
import { fetchAPI } from '$utils/api'
|
||||||
import { PUBLIC_SWELL_STORE_ID } from '$env/static/public'
|
import { PUBLIC_SWELL_STORE_ID } from '$env/static/public'
|
||||||
import { SWELL_API_TOKEN, SWELL_API_ENDPOINT } from '$env/static/private'
|
import { SWELL_API_TOKEN, SWELL_API_ENDPOINT } from '$env/static/private'
|
||||||
@@ -39,7 +40,7 @@ export const load: PageServerLoad = async ({ params }) => {
|
|||||||
// Fetch Swell API for product
|
// Fetch Swell API for product
|
||||||
const shopProductRes: any = await fetch(`${SWELL_API_ENDPOINT}/products/${poster.product_id}`, {
|
const shopProductRes: any = await fetch(`${SWELL_API_ENDPOINT}/products/${poster.product_id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${Buffer.from(`${PUBLIC_SWELL_STORE_ID}:${SWELL_API_TOKEN}`).toString('base64')}`
|
Authorization: `Basic ${base64.encode(`${PUBLIC_SWELL_STORE_ID}:${SWELL_API_TOKEN}`)}`
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const shopProduct = await shopProductRes.json()
|
const shopProduct = await shopProductRes.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user