Remove .env.example and fix auth cookie secure flag
Delete the environment variable example file. Add error handling to the Ollama AI route. Update Docker configuration to support Ollama services and create required image directories. Fix indentation in auth library and allow overriding secure cookie setting in non-production environments.
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
# Database
|
||||
DATABASE_URL=postgresql://user:password@localhost:5432/loam
|
||||
|
||||
# Auth (required for user accounts)
|
||||
JWT_SECRET=change-this-to-a-long-random-string-in-production
|
||||
|
||||
# AI recommendations (optional, defaults shown)
|
||||
OLLAMA_URL=http://localhost:11434
|
||||
OLLAMA_MODEL=llama3.1:8b
|
||||
@@ -27,6 +27,8 @@ COPY --from=builder /app/prisma ./prisma
|
||||
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
|
||||
COPY --from=builder /app/node_modules/prisma ./node_modules/prisma
|
||||
|
||||
RUN mkdir -p /app/public/images/user && chown -R nextjs:nodejs /app/public
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
+16
-3
@@ -4,15 +4,27 @@ services:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- '3333:3000'
|
||||
- "3333:3000"
|
||||
environment:
|
||||
DATABASE_URL: postgresql://bikeapp:bikeapp@db:5432/bikeapp
|
||||
JWT_SECRET: ${JWT_SECRET:-your-super-secret-jwt-key-change-in-production}
|
||||
OLLAMA_URL: http://ollama:11434
|
||||
COOKIE_SECURE: "false"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
# ollama:
|
||||
# condition: service_started
|
||||
restart: unless-stopped
|
||||
|
||||
# ollama:
|
||||
# image: ollama/ollama:latest
|
||||
# ports:
|
||||
# - "11434:11434"
|
||||
# volumes:
|
||||
# - ollama_data:/root/.ollama
|
||||
# restart: unless-stopped
|
||||
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
@@ -22,12 +34,13 @@ services:
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- '5432:5432'
|
||||
- "5432:5432"
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U bikeapp -d bikeapp']
|
||||
test: ["CMD-SHELL", "pg_isready -U bikeapp -d bikeapp"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
# ollama_data:
|
||||
|
||||
@@ -47,7 +47,9 @@ export async function POST(request: Request) {
|
||||
|
||||
const ollamaUrl = process.env.OLLAMA_URL ?? "http://localhost:11434";
|
||||
const model = process.env.OLLAMA_MODEL ?? "llama3.1:8b";
|
||||
const response = await fetch(`${ollamaUrl}/api/chat`, {
|
||||
let response: Response;
|
||||
try {
|
||||
response = await fetch(`${ollamaUrl}/api/chat`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
@@ -63,6 +65,12 @@ export async function POST(request: Request) {
|
||||
],
|
||||
}),
|
||||
});
|
||||
} catch (err) {
|
||||
return NextResponse.json(
|
||||
{ error: `Unable to reach Ollama at ${ollamaUrl}. Is the Ollama service running?` },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
return NextResponse.json(
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ export async function setSessionCookie(token: string) {
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.set(COOKIE_NAME, token, {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
secure: process.env.NODE_ENV === "production" && process.env.COOKIE_SECURE !== "false",
|
||||
sameSite: "lax",
|
||||
maxAge: 60 * 60 * 24 * 7,
|
||||
path: "/",
|
||||
|
||||
Reference in New Issue
Block a user