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 handleDeleteAll = () => {
const deletePromise = fetch("/api/history", {
const deletePromise = fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/history`, {
method: "DELETE",
});

View file

@ -149,7 +149,7 @@ function PureArtifact({
}
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",
body: JSON.stringify({
title: artifact.title,

View file

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

View file

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

View file

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

View file

@ -85,7 +85,7 @@ export function getChatHistoryPaginationKey(
}
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);
@ -94,7 +94,7 @@ export function getChatHistoryPaginationKey(
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 }) {
@ -130,7 +130,7 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
setShowDeleteDialog(false);
const deletePromise = fetch(`/api/chat?id=${chatToDelete}`, {
const deletePromise = fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/chat?id=${chatToDelete}`, {
method: "DELETE",
});

View file

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

View file

@ -18,7 +18,7 @@ export function useChatVisibility({
initialVisibilityType: VisibilityType;
}) {
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(
`${chatId}-visibility`,

View file

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