update hardcoded paths

This commit is contained in:
jeremyphilemon 2026-02-23 08:26:37 -08:00
parent 0c8128cd62
commit 72597d6f68
9 changed files with 23 additions and 18 deletions

View file

@ -41,7 +41,7 @@ export function AppSidebar({ user }: { user: User | undefined }) {
const [showDeleteAllDialog, setShowDeleteAllDialog] = useState(false); const [showDeleteAllDialog, setShowDeleteAllDialog] = useState(false);
const handleDeleteAll = () => { const handleDeleteAll = () => {
const deletePromise = fetch("/api/history", { const deletePromise = fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/history`, {
method: "DELETE", method: "DELETE",
}); });

View file

@ -149,7 +149,7 @@ function PureArtifact({
} }
if (currentDocument.content !== updatedContent) { if (currentDocument.content !== updatedContent) {
await fetch(`/api/document?id=${artifact.documentId}`, { await fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/document?id=${artifact.documentId}`, {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
title: artifact.title, title: artifact.title,

View file

@ -103,7 +103,7 @@ export function Chat({
return shouldContinue; return shouldContinue;
}, },
transport: new DefaultChatTransport({ transport: new DefaultChatTransport({
api: "/api/chat", api: `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/chat`,
fetch: fetchWithErrorHandlers, fetch: fetchWithErrorHandlers,
prepareSendMessagesRequest(request) { prepareSendMessagesRequest(request) {
const lastMessage = request.messages.at(-1); const lastMessage = request.messages.at(-1);
@ -166,12 +166,12 @@ export function Chat({
}); });
setHasAppendedQuery(true); setHasAppendedQuery(true);
window.history.replaceState({}, "", `/chat/${id}`); window.history.replaceState({}, "", `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/chat/${id}`);
} }
}, [query, sendMessage, hasAppendedQuery, id]); }, [query, sendMessage, hasAppendedQuery, id]);
const { data: votes } = useSWR<Vote[]>( const { data: votes } = useSWR<Vote[]>(
messages.length >= 2 ? `/api/vote?chatId=${id}` : null, messages.length >= 2 ? `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/vote?chatId=${id}` : null,
fetcher fetcher
); );
@ -268,7 +268,7 @@ export function Chat({
"https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dadd-credit-card", "https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dadd-credit-card",
"_blank" "_blank"
); );
window.location.href = "/"; window.location.href = `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/`;
}} }}
> >
Activate Activate

View file

@ -77,7 +77,7 @@ export function PureMessageActions({
data-testid="message-upvote" data-testid="message-upvote"
disabled={vote?.isUpvoted} disabled={vote?.isUpvoted}
onClick={() => { onClick={() => {
const upvote = fetch("/api/vote", { const upvote = fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/vote`, {
method: "PATCH", method: "PATCH",
body: JSON.stringify({ body: JSON.stringify({
chatId, chatId,
@ -90,7 +90,7 @@ export function PureMessageActions({
loading: "Upvoting Response...", loading: "Upvoting Response...",
success: () => { success: () => {
mutate<Vote[]>( mutate<Vote[]>(
`/api/vote?chatId=${chatId}`, `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/vote?chatId=${chatId}`,
(currentVotes) => { (currentVotes) => {
if (!currentVotes) { if (!currentVotes) {
return []; return [];
@ -126,7 +126,7 @@ export function PureMessageActions({
data-testid="message-downvote" data-testid="message-downvote"
disabled={vote && !vote.isUpvoted} disabled={vote && !vote.isUpvoted}
onClick={() => { onClick={() => {
const downvote = fetch("/api/vote", { const downvote = fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/vote`, {
method: "PATCH", method: "PATCH",
body: JSON.stringify({ body: JSON.stringify({
chatId, chatId,
@ -139,7 +139,7 @@ export function PureMessageActions({
loading: "Downvoting Response...", loading: "Downvoting Response...",
success: () => { success: () => {
mutate<Vote[]>( mutate<Vote[]>(
`/api/vote?chatId=${chatId}`, `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/vote?chatId=${chatId}`,
(currentVotes) => { (currentVotes) => {
if (!currentVotes) { if (!currentVotes) {
return []; return [];

View file

@ -145,7 +145,7 @@ function PureMultimodalInput({
const [uploadQueue, setUploadQueue] = useState<string[]>([]); const [uploadQueue, setUploadQueue] = useState<string[]>([]);
const submitForm = useCallback(() => { const submitForm = useCallback(() => {
window.history.pushState({}, "", `/chat/${chatId}`); window.history.pushState({}, "", `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/chat/${chatId}`);
sendMessage({ sendMessage({
role: "user", role: "user",
@ -188,7 +188,7 @@ function PureMultimodalInput({
formData.append("file", file); formData.append("file", file);
try { try {
const response = await fetch("/api/files/upload", { const response = await fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/files/upload`, {
method: "POST", method: "POST",
body: formData, body: formData,
}); });

View file

@ -85,7 +85,7 @@ export function getChatHistoryPaginationKey(
} }
if (pageIndex === 0) { if (pageIndex === 0) {
return `/api/history?limit=${PAGE_SIZE}`; return `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/history?limit=${PAGE_SIZE}`;
} }
const firstChatFromPage = previousPageData.chats.at(-1); const firstChatFromPage = previousPageData.chats.at(-1);
@ -94,7 +94,7 @@ export function getChatHistoryPaginationKey(
return null; return null;
} }
return `/api/history?ending_before=${firstChatFromPage.id}&limit=${PAGE_SIZE}`; return `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/history?ending_before=${firstChatFromPage.id}&limit=${PAGE_SIZE}`;
} }
export function SidebarHistory({ user }: { user: User | undefined }) { export function SidebarHistory({ user }: { user: User | undefined }) {
@ -130,7 +130,7 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
setShowDeleteDialog(false); setShowDeleteDialog(false);
const deletePromise = fetch(`/api/chat?id=${chatToDelete}`, { const deletePromise = fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/chat?id=${chatToDelete}`, {
method: "DELETE", method: "DELETE",
}); });

View file

@ -37,7 +37,7 @@ function PureSuggestedActions({ chatId, sendMessage }: SuggestedActionsProps) {
<Suggestion <Suggestion
className="h-auto w-full whitespace-normal p-3 text-left" className="h-auto w-full whitespace-normal p-3 text-left"
onClick={(suggestion) => { onClick={(suggestion) => {
window.history.pushState({}, "", `/chat/${chatId}`); window.history.pushState({}, "", `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/chat/${chatId}`);
sendMessage({ sendMessage({
role: "user", role: "user",
parts: [{ type: "text", text: suggestion }], parts: [{ type: "text", text: suggestion }],

View file

@ -18,7 +18,7 @@ export function useChatVisibility({
initialVisibilityType: VisibilityType; initialVisibilityType: VisibilityType;
}) { }) {
const { mutate, cache } = useSWRConfig(); const { mutate, cache } = useSWRConfig();
const history: ChatHistory = cache.get("/api/history")?.data; const history: ChatHistory = cache.get(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/history`)?.data;
const { data: localVisibility, mutate: setLocalVisibility } = useSWR( const { data: localVisibility, mutate: setLocalVisibility } = useSWR(
`${chatId}-visibility`, `${chatId}-visibility`,

View file

@ -1,8 +1,13 @@
import type { NextConfig } from "next"; import type { NextConfig } from "next";
const basePath = "/demo";
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
basePath: "/demo", basePath,
assetPrefix: "/demo-assets", assetPrefix: "/demo-assets",
env: {
NEXT_PUBLIC_BASE_PATH: basePath,
},
cacheComponents: true, cacheComponents: true,
images: { images: {
remotePatterns: [ remotePatterns: [