Skip to content

Commit a15e61b

Browse files
authored
Consolidate API token environment variables (#204)
1 parent 06c2d47 commit a15e61b

File tree

10 files changed

+10
-12
lines changed

10 files changed

+10
-12
lines changed

.env.development

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
VITE_API_BASE_URL=https://api.dev.zoo.dev
44
VITE_SITE_BASE_URL=https://dev.zoo.dev
5-
#PLAYWRIGHT_SESSION_COOKIE="your-token-from-dev.zoo.dev"
6-
#VITE_TOKEN="your-token-from-dev.zoo.dev"
5+
#VITE_API_TOKEN="your API token"

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ jobs:
7171

7272
- run: yarn test:e2e
7373
env:
74-
PLAYWRIGHT_SESSION_COOKIE: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
75-
VITE_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
74+
VITE_API_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
7675
TAB_API_URL: ${{ secrets.TAB_API_URL }}
7776
TAB_API_KEY: ${{ secrets.TAB_API_KEY }}
7877
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const config: PlaywrightTestConfig = {
1717
cookies: [
1818
{
1919
name: AUTH_COOKIE_NAME,
20-
value: process.env.PLAYWRIGHT_SESSION_COOKIE ?? '',
20+
value: process.env.VITE_API_TOKEN ?? '',
2121
domain: 'localhost',
2222
path: '/',
2323
expires: expiration.getTime() / 1000,

src/routes/(sidebarLayout)/+layout.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const load = async ({ cookies, request, url, fetch }) => {
1111
}
1212

1313
const mockRequestHeader = request.headers.get(PLAYWRIGHT_MOCKING_HEADER)
14-
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_TOKEN
14+
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_API_TOKEN
1515

1616
if (!token) {
1717
signOut()

src/routes/+layout.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { env } from '$lib/env'
33

44
/** @type {import('./$types').LayoutData} */
55
export const load = async ({ locals, cookies }) => {
6-
const token = env.MODE === 'production' ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_TOKEN
6+
const token = env.MODE === 'production' ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_API_TOKEN
77

88
return {
99
user: !locals.user || 'error_code' in locals.user ? undefined : locals.user,

src/routes/+page.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { redirect } from '@sveltejs/kit'
33
import { env } from '$lib/env'
44

55
export const load = async ({ cookies, url }) => {
6-
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_TOKEN
6+
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_API_TOKEN
77

88
if (token) {
99
throw redirect(302, '/dashboard' + (url.search || ''))

src/routes/api/convert/[output_format]/+server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type ConvertResponse = Models['FileConversion_type'] & {
1010
}
1111

1212
export const POST: RequestHandler = async ({ cookies, fetch, request, params }) => {
13-
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_TOKEN
13+
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_API_TOKEN
1414
if (!token) throw error(401, 'You must be logged in to use this API.')
1515

1616
const body = await request.text()

src/routes/api/get-generation/+server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type LoadResponse = {
99
}
1010

1111
export const POST: RequestHandler = async ({ cookies, fetch, request }) => {
12-
const token = env.MODE === 'production' ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_TOKEN
12+
const token = env.MODE === 'production' ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_API_TOKEN
1313

1414
const body = await request.json()
1515

src/routes/api/submit-feedback/+server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type LoadResponse = {
99
}
1010

1111
export const POST: RequestHandler = async ({ cookies, fetch, request }) => {
12-
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_TOKEN
12+
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_API_TOKEN
1313
const body = await request.json()
1414

1515
if (!(body?.id && body?.feedback))

src/routes/api/submit-prompt/+server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type PromptLoadResponse = {
1010
}
1111

1212
export const POST: RequestHandler = async ({ cookies, fetch, request }) => {
13-
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_TOKEN
13+
const token = env.PROD ? cookies.get(AUTH_COOKIE_NAME) : env.VITE_API_TOKEN
1414
if (!token) throw error(401, 'You must be logged in to use this API.')
1515

1616
const body = await request.json()

0 commit comments

Comments
 (0)