Skip to content

Commit de2df1a

Browse files
authored
Add ALLOW_INSECURE_COOKIES feature flag (#1076)
1 parent 3d83131 commit de2df1a

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,4 @@ WEBHOOK_URL_REPORT_ASSISTANT=#provide webhook url to get notified when an assist
153153
ALLOWED_USER_EMAILS=`[]` # if it's defined, only these emails will be allowed to use the app
154154

155155
USAGE_LIMITS=`{}`
156+
ALLOW_INSECURE_COOKIES=false # recommended to keep this to false but set to true if you need to run over http without tls

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ A chat interface using open source models, eg OpenAssistant or Llama. It is a Sv
2424
3. [Web Search](#web-search)
2525
4. [Text Embedding Models](#text-embedding-models)
2626
5. [Extra parameters](#extra-parameters)
27-
6. [Deploying to a HF Space](#deploying-to-a-hf-space)
28-
7. [Building](#building)
27+
6. [Common issues](#common-issues)
28+
7. [Deploying to a HF Space](#deploying-to-a-hf-space)
29+
8. [Building](#building)
2930

3031
## No Setup Deploy
3132

@@ -735,6 +736,14 @@ MODELS=`[
735736
]`
736737
```
737738

739+
## Common issues
740+
741+
### 403:You don't have access to this conversation
742+
743+
Most likely you are running chat-ui over HTTP. The recommended option is to setup something like NGINX to handle HTTPS and proxy the requests to chat-ui. If you really need to run over HTTP you can add `ALLOW_INSECURE_COOKIES=true` to your `.env.local`.
744+
745+
Make sure to set your `PUBLIC_ORIGIN` in your `.env.local` to the correct URL as well.
746+
738747
## Deploying to a HF Space
739748

740749
Create a `DOTENV_LOCAL` secret to your HF space with the content of your .env.local, and they will be picked up automatically when you run.

src/lib/server/auth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
OPENID_TOLERANCE,
1111
OPENID_RESOURCE,
1212
OPENID_CONFIG,
13+
ALLOW_INSECURE_COOKIES,
1314
} from "$env/static/private";
1415
import { sha256 } from "$lib/utils/sha256";
1516
import { z } from "zod";
@@ -55,7 +56,7 @@ export function refreshSessionCookie(cookies: Cookies, sessionId: string) {
5556
path: "/",
5657
// So that it works inside the space's iframe
5758
sameSite: dev ? "lax" : "none",
58-
secure: !dev,
59+
secure: !dev && !(ALLOW_INSECURE_COOKIES === "true"),
5960
httpOnly: true,
6061
expires: addWeeks(new Date(), 2),
6162
});

src/routes/logout/+page.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { dev } from "$app/environment";
22
import { base } from "$app/paths";
3-
import { COOKIE_NAME } from "$env/static/private";
3+
import { COOKIE_NAME, ALLOW_INSECURE_COOKIES } from "$env/static/private";
44
import { collections } from "$lib/server/database";
55
import { redirect } from "@sveltejs/kit";
66

@@ -12,7 +12,7 @@ export const actions = {
1212
path: "/",
1313
// So that it works inside the space's iframe
1414
sameSite: dev ? "lax" : "none",
15-
secure: !dev,
15+
secure: !dev && !(ALLOW_INSECURE_COOKIES === "true"),
1616
httpOnly: true,
1717
});
1818
throw redirect(303, `${base}/`);

0 commit comments

Comments
 (0)