Spaces:
Runtime error
Runtime error
Commit ·
e5d90fd
1
Parent(s): 94b5741
added email
Browse files- .gitignore +3 -0
- backend/app/config.py +7 -1
- frontend/.env.example +0 -2
- frontend/src/pages/AuthPage.tsx +4 -2
- frontend/vite.config.ts +4 -0
- renderer/package.json +1 -1
.gitignore
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
|
|
| 1 |
.env
|
|
|
|
|
|
|
| 2 |
node_modules/
|
| 3 |
dist/
|
| 4 |
.venv/
|
|
|
|
| 1 |
+
# Secrets: any .env at any depth, plus .env.local / .env.production etc. Templates stay tracked.
|
| 2 |
.env
|
| 3 |
+
.env.*
|
| 4 |
+
!.env.example
|
| 5 |
node_modules/
|
| 6 |
dist/
|
| 7 |
.venv/
|
backend/app/config.py
CHANGED
|
@@ -1,10 +1,16 @@
|
|
| 1 |
from functools import lru_cache
|
|
|
|
| 2 |
|
| 3 |
from pydantic_settings import BaseSettings, SettingsConfigDict
|
| 4 |
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
class Settings(BaseSettings):
|
| 7 |
-
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
| 8 |
|
| 9 |
env: str = "development"
|
| 10 |
app_name: str = "Notestack"
|
|
|
|
| 1 |
from functools import lru_cache
|
| 2 |
+
from pathlib import Path
|
| 3 |
|
| 4 |
from pydantic_settings import BaseSettings, SettingsConfigDict
|
| 5 |
|
| 6 |
|
| 7 |
+
# One .env at the repo root serves every way of running the API; a backend/.env (or the
|
| 8 |
+
# working directory's .env) overrides it. Real environment variables beat both.
|
| 9 |
+
_ROOT_ENV = Path(__file__).resolve().parents[2] / ".env"
|
| 10 |
+
|
| 11 |
+
|
| 12 |
class Settings(BaseSettings):
|
| 13 |
+
model_config = SettingsConfigDict(env_file=(_ROOT_ENV, ".env"), extra="ignore")
|
| 14 |
|
| 15 |
env: str = "development"
|
| 16 |
app_name: str = "Notestack"
|
frontend/.env.example
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
VITE_API_URL=
|
| 2 |
-
VITE_GOOGLE_CLIENT_ID=
|
|
|
|
|
|
|
|
|
frontend/src/pages/AuthPage.tsx
CHANGED
|
@@ -21,7 +21,9 @@ declare global {
|
|
| 21 |
}
|
| 22 |
}
|
| 23 |
|
| 24 |
-
const GOOGLE_CLIENT_ID = import.meta.env.VITE_GOOGLE_CLIENT_ID
|
|
|
|
|
|
|
| 25 |
|
| 26 |
function GoogleButton({ onCredential }: { onCredential: (c: string) => void }) {
|
| 27 |
const ref = useRef<HTMLDivElement>(null);
|
|
@@ -47,7 +49,7 @@ function GoogleButton({ onCredential }: { onCredential: (c: string) => void }) {
|
|
| 47 |
}, [onCredential]);
|
| 48 |
|
| 49 |
if (!GOOGLE_CLIENT_ID) {
|
| 50 |
-
return <p className="mono muted auth-hint">Set
|
| 51 |
}
|
| 52 |
return <div ref={ref} className="google-btn" />;
|
| 53 |
}
|
|
|
|
| 21 |
}
|
| 22 |
}
|
| 23 |
|
| 24 |
+
const GOOGLE_CLIENT_ID = (import.meta.env.VITE_GOOGLE_CLIENT_ID || import.meta.env.GOOGLE_CLIENT_ID) as
|
| 25 |
+
| string
|
| 26 |
+
| undefined;
|
| 27 |
|
| 28 |
function GoogleButton({ onCredential }: { onCredential: (c: string) => void }) {
|
| 29 |
const ref = useRef<HTMLDivElement>(null);
|
|
|
|
| 49 |
}, [onCredential]);
|
| 50 |
|
| 51 |
if (!GOOGLE_CLIENT_ID) {
|
| 52 |
+
return <p className="mono muted auth-hint">Set GOOGLE_CLIENT_ID in .env to enable Google sign in.</p>;
|
| 53 |
}
|
| 54 |
return <div ref={ref} className="google-btn" />;
|
| 55 |
}
|
frontend/vite.config.ts
CHANGED
|
@@ -3,6 +3,10 @@ import react from "@vitejs/plugin-react";
|
|
| 3 |
|
| 4 |
export default defineConfig({
|
| 5 |
plugins: [react()],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
server: {
|
| 7 |
port: 5173,
|
| 8 |
proxy: { "/api": process.env.VITE_API_PROXY ?? "http://localhost:8000" },
|
|
|
|
| 3 |
|
| 4 |
export default defineConfig({
|
| 5 |
plugins: [react()],
|
| 6 |
+
// Read the shared root .env. Only these prefixes reach the browser; the Google client ID is
|
| 7 |
+
// public by design, so it can be shared with the backend under its plain name.
|
| 8 |
+
envDir: "..",
|
| 9 |
+
envPrefix: ["VITE_", "GOOGLE_CLIENT_ID"],
|
| 10 |
server: {
|
| 11 |
port: 5173,
|
| 12 |
proxy: { "/api": process.env.VITE_API_PROXY ?? "http://localhost:8000" },
|
renderer/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
"type": "module",
|
| 6 |
"scripts": {
|
| 7 |
"studio": "remotion studio src/index.ts",
|
| 8 |
-
"start": "tsx server/index.ts",
|
| 9 |
"typecheck": "tsc --noEmit"
|
| 10 |
},
|
| 11 |
"dependencies": {
|
|
|
|
| 5 |
"type": "module",
|
| 6 |
"scripts": {
|
| 7 |
"studio": "remotion studio src/index.ts",
|
| 8 |
+
"start": "tsx --env-file-if-exists=../.env server/index.ts",
|
| 9 |
"typecheck": "tsc --noEmit"
|
| 10 |
},
|
| 11 |
"dependencies": {
|