Skip to content

Commit

Permalink
Feat: customizable vars
Browse files Browse the repository at this point in the history
  • Loading branch information
sverben committed Jan 21, 2024
1 parent 35f331e commit 3dc6f05
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Api } from "../__generated__/api"
import { jwtDecode } from 'jwt-decode'

const OAUTH_SERVER = "http://localhost:8000/o"
const CLIENT_ID = '9COYxKq9FZVr2WFtFqtkkpM8mdS8Qe23D1ohVNn1'
const OAUTH_SERVER = import.meta.env.VITE_OAUTH_SERVER
const CLIENT_ID = import.meta.env.VITE_CLIENT_ID
const API_BASE = import.meta.env.VITE_API_BASE
const SCOPES = ['openid', 'user/basic', 'media']

const urlParams = new URLSearchParams(window.location.search)
Expand Down Expand Up @@ -35,7 +36,7 @@ if (!token || (decoded?.exp||0) * 1000 < Date.now()) {
}

export default new Api({
baseUrl: "http://localhost:7000",
baseUrl: API_BASE,
baseApiParams: {
credentials: "same-origin",
headers: {
Expand Down
10 changes: 10 additions & 0 deletions client/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
/// <reference types="svelte" />
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_OAUTH_SERVER: string
readonly VITE_CLIENT_ID: string
readonly VITE_API_BASE: string
}

interface ImportMeta {
readonly env: ImportMetaEnv
}
1 change: 1 addition & 0 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"allowJs": true,
"checkJs": true,
"isolatedModules": true,
"baseUrl": ".",
"paths": {
"$lib/*": ["src/lib/*"],
}
Expand Down

0 comments on commit 3dc6f05

Please sign in to comment.