Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

docs: update environment setup instructions and add troubleshooting guide for common issues

Andrej Acevskib5d957367ba6
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8ec9ca9a1..cc1c35c82 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -46,8 +46,12 @@ pnpm install
3. **Set up environment variables**:
```bash
-# Create a .env file in the API directory
-echo "JWT_ACCESS=your-development-secret-here" > apps/api/.env
+# Copy the sample environment files
+cp apps/api/.env.sample apps/api/.env
+cp apps/web/.env.sample apps/web/.env
+
+# Update the environment variables as needed
+# See ENVIRONMENT_SETUP.md for detailed instructions
```
4. **Start everything up**:
@@ -59,6 +63,8 @@ This starts both the API (port 1337) and web app (port 5173). Both will automati
> **Tip**: The web app at http://localhost:5173 will automatically connect to the API at http://localhost:1337
+> **Need help with setup?** See our [Environment Setup Guide](ENVIRONMENT_SETUP.md) for detailed instructions and troubleshooting tips.
+
## Making Your First Contribution
### Finding Something to Work On
diff --git a/ENVIRONMENT_SETUP.md b/ENVIRONMENT_SETUP.md
new file mode 100644
index 000000000..4db09a20a
--- /dev/null
+++ b/ENVIRONMENT_SETUP.md
@@ -0,0 +1,180 @@
+# Environment Setup Guide
+
+This guide will help you set up the Kaneo development environment and troubleshoot common issues.
+
+## Quick Start
+
+1. Copy the sample environment files:
+ ```bash
+ cp apps/api/.env.sample apps/api/.env
+ cp apps/web/.env.sample apps/web/.env
+ ```
+
+2. Update the environment variables in both files (see sections below)
+
+3. Start the development servers:
+ ```bash
+ pnpm dev
+ ```
+
+## API Environment Variables
+
+Create `apps/api/.env` with the following variables:
+
+### Required Variables
+
+- `DATABASE_URL`: PostgreSQL connection string
+ ```
+ DATABASE_URL=postgresql://kaneo_user:kaneo_password@localhost:5432/kaneo
+ ```
+
+- `JWT_ACCESS`: Secret key for JWT token generation
+ ```
+ JWT_ACCESS=your-development-secret-here
+ ```
+
+### Optional Variables
+
+- `DISABLE_REGISTRATION`: Set to "true" to disable new user registration
+- `DEMO_MODE`: Set to "true" to enable demo mode for testing
+- `CORS_ORIGINS`: Comma-separated list of allowed origins
+ ```
+ CORS_ORIGINS=http://localhost:3000,https://yourdomain.com
+ ```
+- `PORT`: API server port (default: 1337)
+
+### GitHub Integration (Optional)
+
+- `GITHUB_APP_ID`: GitHub App ID for repository integration
+- `GITHUB_PRIVATE_KEY`: GitHub App Private Key (PEM format)
+- `GITHUB_WEBHOOK_SECRET`: GitHub App Webhook Secret
+- `GITHUB_APP_NAME`: GitHub App Name
+
+## Frontend Environment Variables
+
+Create `apps/web/.env` with the following variables:
+
+### Required Variables
+
+- `VITE_API_URL`: URL of the API server
+ ```
+ VITE_API_URL=http://localhost:1337
+ ```
+
+### Optional Variables
+
+- `VITE_APP_URL`: App URL for generating links
+ ```
+ VITE_APP_URL=http://localhost:3000
+ ```
+
+## Common Issues & Troubleshooting
+
+### CORS Errors
+
+**Symptoms:**
+- "Failed to fetch" errors in browser console
+- Network errors when making API requests
+- "Access to fetch at '...' from origin '...' has been blocked by CORS policy"
+
+**Solutions:**
+
+1. **Check API URL Configuration:**
+ - Ensure `VITE_API_URL` in frontend `.env` matches your API server URL
+ - Verify the API server is running on the correct port
+
+2. **Configure CORS Origins:**
+ - Add your frontend URL to `CORS_ORIGINS` in API `.env`:
+ ```
+ CORS_ORIGINS=http://localhost:3000,https://yourdomain.com
+ ```
+ - For development, you can leave `CORS_ORIGINS` empty to allow all origins
+
+3. **Check Protocol Consistency:**
+ - Ensure both frontend and API use the same protocol (http/https)
+ - Don't mix http and https in development
+
+4. **Verify Server Accessibility:**
+ - Test if the API is accessible: `curl http://localhost:1337/config`
+ - Check if the server is running on the correct port
+
+### Database Connection Issues
+
+**Symptoms:**
+- "Database connection failed" errors
+- API server won't start
+
+**Solutions:**
+
+1. **Check PostgreSQL:**
+ - Ensure PostgreSQL is running
+ - Verify database exists and credentials are correct
+ - Test connection: `psql postgresql://kaneo_user:kaneo_password@localhost:5432/kaneo`
+
+2. **Update DATABASE_URL:**
+ - Ensure the connection string format is correct
+ - Check username, password, host, port, and database name
+
+### Authentication Issues
+
+**Symptoms:**
+- "Authentication failed" errors
+- Users can't sign in
+
+**Solutions:**
+
+1. **Check JWT Configuration:**
+ - Ensure `JWT_ACCESS` is set in API `.env`
+ - Use a strong secret in production
+
+2. **Clear Browser Data:**
+ - Clear cookies and local storage
+ - Try in incognito/private mode
+
+### Network Errors
+
+**Symptoms:**
+- "Network error" messages
+- API requests timeout
+
+**Solutions:**
+
+1. **Check Server Status:**
+ - Verify API server is running
+ - Check server logs for errors
+
+2. **Check Firewall/Proxy:**
+ - Ensure ports are not blocked
+ - Check if proxy settings interfere
+
+3. **Verify URLs:**
+ - Check that all URLs are accessible
+ - Test with curl or browser
+
+## Development vs Production
+
+### Development
+- Use `http://localhost` for both frontend and API
+- Leave `CORS_ORIGINS` empty to allow all origins
+- Use simple JWT secrets (not for production)
+
+### Production
+- Use HTTPS for both frontend and API
+- Set specific `CORS_ORIGINS` for security
+- Use strong, unique JWT secrets
+- Configure proper database credentials
+
+## Getting Help
+
+If you're still experiencing issues:
+
+1. Check the browser console for detailed error messages
+2. Review the API server logs
+3. Verify all environment variables are set correctly
+4. Ensure all services (PostgreSQL, API, Frontend) are running
+
+The application now includes enhanced error handling that will provide specific troubleshooting steps for common issues like CORS problems.
+
+## Testing Error Handling
+
+You can test the error handling by visiting `/test-error` in your browser. This will show you how the error display component looks and what troubleshooting steps are provided for different types of errors.
\ No newline at end of file
diff --git a/README.md b/README.md
index c38aa1a15..e83c611f0 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,8 @@ We built Kaneo because existing project management tools either feel bloated wit
## Getting Started
+### Quick Start with Docker Compose
+
The fastest way to try Kaneo is with Docker Compose. This sets up the API, web interface, and PostgreSQL database:
```yaml
@@ -83,6 +85,10 @@ Save this as `compose.yml`, run `docker compose up -d`, and open [http://localho
> **Quick tip:** Change `JWT_ACCESS` to something secure in production. This is used to sign authentication tokens.
+### Development Setup
+
+For development, see our [Environment Setup Guide](ENVIRONMENT_SETUP.md) for detailed instructions on configuring environment variables and troubleshooting common issues like CORS problems.
+
### Configuration Options
| Variable | What it does | Default |
@@ -143,34 +149,26 @@ Check the [Helm chart docs](./charts/kaneo/README.md) for TLS setup, cert-manage
## Development
-Want to hack on Kaneo? Here's how to get a development environment running:
+Want to hack on Kaneo? See our [Environment Setup Guide](ENVIRONMENT_SETUP.md) for detailed instructions on configuring environment variables and troubleshooting common issues like CORS problems.
+Quick start:
```bash
# Clone and install dependencies
git clone https://github.com/usekaneo/kaneo.git
cd kaneo
pnpm install
-# Start PostgreSQL (using Docker)
-docker run --name kaneo-postgres -e POSTGRES_DB=kaneo -e POSTGRES_USER=kaneo_user -e POSTGRES_PASSWORD=kaneo_password -p 5432:5432 -d postgres:16-alpine
+# Copy environment files
+cp apps/api/.env.sample apps/api/.env
+cp apps/web/.env.sample apps/web/.env
-# Set up environment variables
-cd apps/api
-echo "DATABASE_URL=postgresql://kaneo_user:kaneo_password@localhost:5432/kaneo" > .env
+# Update environment variables as needed
+# See ENVIRONMENT_SETUP.md for detailed instructions
-# Run database migrations
-pnpm run db:migrate
-
-# Start the API
-pnpm run dev
-
-# In another terminal, start the web app
-cd apps/web
-pnpm run dev
+# Start development servers
+pnpm dev
```
-The API runs on port 1337, web app on 5173. Both will reload when you make changes.
-
## Migration from SQLite
If you're upgrading from a previous version that used SQLite, you'll need to migrate your data to PostgreSQL. We recommend:
diff --git a/apps/api/.env.sample b/apps/api/.env.sample
new file mode 100644
index 000000000..82054d808
--- /dev/null
+++ b/apps/api/.env.sample
@@ -0,0 +1,36 @@
+# Database Configuration
+# PostgreSQL connection string
+DATABASE_URL=postgresql://kaneo_user:kaneo_password@localhost:5432/kaneo
+
+# JWT Configuration
+# Secret key for JWT token generation (change this in production!)
+JWT_ACCESS=your-development-secret-here
+
+# Application Settings
+# Disable new user registration (set to "true" to disable)
+DISABLE_REGISTRATION=false
+
+# Enable demo mode for testing (set to "true" to enable)
+DEMO_MODE=false
+
+# GitHub Integration (Optional)
+# GitHub App ID for repository integration
+GITHUB_APP_ID=
+
+# GitHub App Private Key (PEM format)
+GITHUB_PRIVATE_KEY=
+
+# GitHub App Webhook Secret
+GITHUB_WEBHOOK_SECRET=
+
+# GitHub App Name (used for installation URLs)
+GITHUB_APP_NAME=
+
+# CORS Configuration
+# Comma-separated list of allowed origins (optional, defaults to "*")
+# Example: CORS_ORIGINS=http://localhost:3000,https://yourdomain.com
+CORS_ORIGINS=
+
+# Server Configuration
+# Port for the API server (default: 1337)
+PORT=1337
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index ba2df3b20..d2bebc7fa 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -27,11 +27,25 @@ import workspaceUser from "./workspace-user";
const app = new Hono<{ Variables: { userEmail: string } }>();
const { isDemoMode } = getSettings();
+const corsOrigins = process.env.CORS_ORIGINS
+ ? process.env.CORS_ORIGINS.split(",").map((origin) => origin.trim())
+ : undefined;
+
app.use(
"*",
cors({
credentials: true,
- origin: (origin) => origin || "*",
+ origin: (origin) => {
+ if (!corsOrigins) {
+ return origin || "*";
+ }
+
+ if (!origin) {
+ return null;
+ }
+
+ return corsOrigins.includes(origin) ? origin : null;
+ },
}),
);
diff --git a/apps/web/.env.sample b/apps/web/.env.sample
new file mode 100644
index 000000000..cb197e50f
--- /dev/null
+++ b/apps/web/.env.sample
@@ -0,0 +1,14 @@
+# Frontend Environment Variables
+# Copy this file to .env and update the values as needed
+
+# API URL for the frontend to connect to
+# This should match your API server URL and CORS configuration
+# IMPORTANT: Make sure this matches the CORS_ORIGINS in your API configuration
+VITE_API_URL=http://localhost:1337
+
+# App URL for generating links (optional)
+VITE_APP_URL=http://localhost:3000
+
+# Development Configuration
+# Set to true to enable development features
+VITE_DEV_MODE=false
diff --git a/apps/web/src/components/providers/auth-provider/index.tsx b/apps/web/src/components/providers/auth-provider/index.tsx
index eac8bf404..f930bb185 100644
--- a/apps/web/src/components/providers/auth-provider/index.tsx
+++ b/apps/web/src/components/providers/auth-provider/index.tsx
@@ -10,6 +10,7 @@ import {
useMemo,
useState,
} from "react";
+import { ErrorDisplay } from "../../ui/error-display";
export const AuthContext = createContext<{
user: LoggedInUser | null | undefined;
@@ -21,7 +22,7 @@ export const AuthContext = createContext<{
function AuthProvider({ children }: PropsWithChildren) {
const [user, setUser] = useState<LoggedInUser | undefined | null>(undefined);
- const { data, isFetching } = useGetMe();
+ const { data, isFetching, error } = useGetMe();
useEffect(() => {
if (data?.user === null) {
@@ -39,6 +40,16 @@ function AuthProvider({ children }: PropsWithChildren) {
[user],
);
+ if (error) {
+ return (
+ <ErrorDisplay
+ error={error}
+ title="Connection Error"
+ className="min-h-screen"
+ />
+ );
+ }
+
if (isFetching || user === undefined) {
return (
<div className="flex w-full items-center justify-center h-screen flex-col md:flex-row bg-zinc-50 dark:bg-zinc-950">
diff --git a/apps/web/src/components/ui/error-boundary.tsx b/apps/web/src/components/ui/error-boundary.tsx
new file mode 100644
index 000000000..1ccbee668
--- /dev/null
+++ b/apps/web/src/components/ui/error-boundary.tsx
@@ -0,0 +1,58 @@
+import React from "react";
+import { ErrorDisplay } from "./error-display";
+
+interface ErrorBoundaryState {
+ hasError: boolean;
+ error?: Error;
+}
+
+interface ErrorBoundaryProps {
+ children: React.ReactNode;
+ fallback?: React.ComponentType<{ error: Error; resetError: () => void }>;
+}
+
+export class ErrorBoundary extends React.Component<
+ ErrorBoundaryProps,
+ ErrorBoundaryState
+> {
+ constructor(props: ErrorBoundaryProps) {
+ super(props);
+ this.state = { hasError: false };
+ }
+
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState {
+ return { hasError: true, error };
+ }
+
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
+ console.error("Error caught by boundary:", error, errorInfo);
+ }
+
+ resetError = () => {
+ this.setState({ hasError: false, error: undefined });
+ };
+
+ render() {
+ if (this.state.hasError) {
+ if (this.props.fallback && this.state.error) {
+ const FallbackComponent = this.props.fallback;
+ return (
+ <FallbackComponent
+ error={this.state.error}
+ resetError={this.resetError}
+ />
+ );
+ }
+
+ return (
+ <ErrorDisplay
+ error={this.state.error}
+ onRetry={this.resetError}
+ title="Something went wrong"
+ />
+ );
+ }
+
+ return this.props.children;
+ }
+}
diff --git a/apps/web/src/components/ui/error-display.tsx b/apps/web/src/components/ui/error-display.tsx
new file mode 100644
index 000000000..9f210d5fc
--- /dev/null
+++ b/apps/web/src/components/ui/error-display.tsx
@@ -0,0 +1,119 @@
+import { AlertTriangle, ExternalLink, RefreshCw } from "lucide-react";
+import {
+ getCorsTroubleshootingSteps,
+ getNetworkTroubleshootingSteps,
+ parseApiError,
+} from "../../lib/error-handler";
+import { Button } from "./button";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+} from "./card";
+
+interface ErrorDisplayProps {
+ error: unknown;
+ onRetry?: () => void;
+ title?: string;
+ className?: string;
+}
+
+export function ErrorDisplay({
+ error,
+ onRetry,
+ title = "Something went wrong",
+ className,
+}: ErrorDisplayProps) {
+ const parsedError = parseApiError(error);
+
+ const getTroubleshootingSteps = () => {
+ switch (parsedError.type) {
+ case "cors":
+ return getCorsTroubleshootingSteps();
+ case "network":
+ return getNetworkTroubleshootingSteps();
+ default:
+ return [];
+ }
+ };
+
+ const troubleshootingSteps = getTroubleshootingSteps();
+
+ return (
+ <div
+ className={`flex items-center justify-center min-h-[400px] p-6 ${className}`}
+ >
+ <Card className="w-full max-w-md">
+ <CardHeader className="text-center">
+ <div className="mx-auto w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center mb-4">
+ <AlertTriangle className="w-6 h-6 text-red-600 dark:text-red-400" />
+ </div>
+ <CardTitle className="text-lg">{title}</CardTitle>
+ <CardDescription className="text-sm">
+ {parsedError.message}
+ </CardDescription>
+ </CardHeader>
+ <CardContent className="space-y-4">
+ {troubleshootingSteps.length > 0 && (
+ <div className="space-y-2">
+ <h4 className="text-sm font-medium text-zinc-900 dark:text-zinc-100">
+ Troubleshooting steps:
+ </h4>
+ <ul className="text-xs text-zinc-600 dark:text-zinc-400 space-y-1">
+ {troubleshootingSteps.map((step, index) => (
+ <li
+ key={`step-${index}-${step.slice(0, 10)}`}
+ className="flex items-start gap-2"
+ >
+ <span className="text-zinc-400 dark:text-zinc-500 mt-0.5">
+ •
+ </span>
+ <span>{step}</span>
+ </li>
+ ))}
+ </ul>
+ </div>
+ )}
+
+ <div className="flex flex-col gap-2 pt-2">
+ {onRetry && (
+ <Button
+ onClick={onRetry}
+ variant="outline"
+ size="sm"
+ className="w-full"
+ >
+ <RefreshCw className="w-4 h-4 mr-2" />
+ Try Again
+ </Button>
+ )}
+
+ {parsedError.type === "cors" && (
+ <Button
+ onClick={() => window.open("https://kaneo.app/docs", "_blank")}
+ variant="outline"
+ size="icon"
+ className="w-full"
+ >
+ <ExternalLink className="w-4 h-4 mr-2" />
+ View Deployment Guide
+ </Button>
+ )}
+
+ <Button
+ onClick={() => window.location.reload()}
+ variant="outline"
+ size="icon"
+ className="w-full"
+ >
+ <RefreshCw className="w-4 h-4 mr-2" />
+ Refresh Page
+ </Button>
+ </div>
+ </CardContent>
+ </Card>
+ </div>
+ );
+}
diff --git a/apps/web/src/components/ui/error-fallback.tsx b/apps/web/src/components/ui/error-fallback.tsx
new file mode 100644
index 000000000..bcf2d7c47
--- /dev/null
+++ b/apps/web/src/components/ui/error-fallback.tsx
@@ -0,0 +1,17 @@
+import { ErrorDisplay } from "./error-display";
+
+interface ErrorFallbackProps {
+ error: Error;
+ resetError: () => void;
+}
+
+export function ErrorFallback({ error, resetError }: ErrorFallbackProps) {
+ return (
+ <ErrorDisplay
+ error={error}
+ onRetry={resetError}
+ title="Something went wrong"
+ className="min-h-screen"
+ />
+ );
+}
diff --git a/apps/web/src/components/ui/error-test.tsx b/apps/web/src/components/ui/error-test.tsx
new file mode 100644
index 000000000..5ff465a8f
--- /dev/null
+++ b/apps/web/src/components/ui/error-test.tsx
@@ -0,0 +1,18 @@
+import { ErrorDisplay } from "./error-display";
+
+export function ErrorTest() {
+ const testError = new Error(
+ "Failed to connect to API server at https://api.andrej.com. This might be due to CORS configuration issues or the server not running. Please check your environment variables and server status.",
+ );
+
+ return (
+ <div className="p-4">
+ <h2 className="text-lg font-semibold mb-4">Error Handling Test</h2>
+ <ErrorDisplay
+ error={testError}
+ title="Test Error"
+ className="min-h-[300px]"
+ />
+ </div>
+ );
+}
diff --git a/apps/web/src/lib/error-handler.ts b/apps/web/src/lib/error-handler.ts
new file mode 100644
index 000000000..aecbe0c17
--- /dev/null
+++ b/apps/web/src/lib/error-handler.ts
@@ -0,0 +1,93 @@
+export interface ApiError {
+ message: string;
+ type: "network" | "cors" | "auth" | "server" | "unknown";
+ status?: number;
+ originalError?: Error;
+}
+
+export function parseApiError(error: unknown): ApiError {
+ if (error instanceof Error) {
+ if (
+ error.message.includes("Failed to fetch") ||
+ error.message.includes("NetworkError") ||
+ error.message.includes("CORS")
+ ) {
+ return {
+ message:
+ "Unable to connect to the server. This might be due to CORS configuration issues.",
+ type: "cors",
+ originalError: error,
+ };
+ }
+
+ if (
+ error.message.includes("fetch") ||
+ error.message.includes("network") ||
+ error.message.includes("connection")
+ ) {
+ return {
+ message:
+ "Network error. Please check your internet connection and try again.",
+ type: "network",
+ originalError: error,
+ };
+ }
+
+ if (
+ error.message.includes("401") ||
+ error.message.includes("unauthorized") ||
+ error.message.includes("authentication")
+ ) {
+ return {
+ message: "Authentication failed. Please sign in again.",
+ type: "auth",
+ status: 401,
+ originalError: error,
+ };
+ }
+
+ // Check for server errors
+ if (
+ error.message.includes("500") ||
+ error.message.includes("server error") ||
+ error.message.includes("internal")
+ ) {
+ return {
+ message: "Server error. Please try again later.",
+ type: "server",
+ status: 500,
+ originalError: error,
+ };
+ }
+
+ return {
+ message: error.message || "An unexpected error occurred.",
+ type: "unknown",
+ originalError: error,
+ };
+ }
+
+ return {
+ message: "An unexpected error occurred.",
+ type: "unknown",
+ };
+}
+
+export function getCorsTroubleshootingSteps(): string[] {
+ return [
+ "Make sure your API server is running",
+ "Check that VITE_API_URL in your frontend .env matches your API server URL",
+ "Verify CORS_ORIGINS in your API .env includes your frontend URL",
+ "Ensure both frontend and API are using the same protocol (http/https)",
+ "Check that your API server is accessible from your browser",
+ ];
+}
+
+export function getNetworkTroubleshootingSteps(): string[] {
+ return [
+ "Check your internet connection",
+ "Verify the API server is running and accessible",
+ "Try refreshing the page",
+ "Check if there are any firewall or proxy issues",
+ ];
+}
diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx
index 22f761405..857838c92 100644
--- a/apps/web/src/main.tsx
+++ b/apps/web/src/main.tsx
@@ -7,6 +7,8 @@ import "@/index.css";
import AuthProvider from "./components/providers/auth-provider";
import useAuth from "./components/providers/auth-provider/hooks/use-auth";
import { ThemeProvider } from "./components/providers/theme-provider";
+import { ErrorBoundary } from "./components/ui/error-boundary";
+import { ErrorFallback } from "./components/ui/error-fallback";
import { KeyboardShortcutsProvider } from "./hooks/use-keyboard-shortcuts";
import { routeTree } from "./routeTree.gen";
@@ -37,15 +39,17 @@ if (!rootElement.innerHTML) {
const root = createRoot(rootElement);
root.render(
<StrictMode>
- <QueryClientProvider client={queryClient}>
- <ThemeProvider>
- <AuthProvider>
- <KeyboardShortcutsProvider>
- <App />
- </KeyboardShortcutsProvider>
- </AuthProvider>
- </ThemeProvider>
- </QueryClientProvider>
+ <ErrorBoundary fallback={ErrorFallback}>
+ <QueryClientProvider client={queryClient}>
+ <ThemeProvider>
+ <AuthProvider>
+ <KeyboardShortcutsProvider>
+ <App />
+ </KeyboardShortcutsProvider>
+ </AuthProvider>
+ </ThemeProvider>
+ </QueryClientProvider>
+ </ErrorBoundary>
</StrictMode>,
);
}
diff --git a/apps/web/src/query-client/index.ts b/apps/web/src/query-client/index.ts
index eddc9faee..cd99d3bf9 100644
--- a/apps/web/src/query-client/index.ts
+++ b/apps/web/src/query-client/index.ts
@@ -5,6 +5,20 @@ const queryClient = new QueryClient({
queries: {
refetchOnWindowFocus: false,
refetchOnMount: false,
+ retry: (failureCount, error) => {
+ if (error instanceof Error) {
+ if (
+ error.message.includes("Failed to fetch") ||
+ error.message.includes("NetworkError") ||
+ error.message.includes("CORS")
+ ) {
+ return false;
+ }
+ }
+ return failureCount < 2;
+ },
+ },
+ mutations: {
retry: false,
},
},
diff --git a/apps/web/src/routeTree.gen.ts b/apps/web/src/routeTree.gen.ts
index bae8e661c..eaa214b71 100644
--- a/apps/web/src/routeTree.gen.ts
+++ b/apps/web/src/routeTree.gen.ts
@@ -9,6 +9,7 @@
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
import { Route as rootRouteImport } from './routes/__root'
+import { Route as TestErrorRouteImport } from './routes/test-error'
import { Route as DashboardRouteImport } from './routes/dashboard'
import { Route as IndexRouteImport } from './routes/index'
import { Route as PublicProjectProjectIdRouteImport } from './routes/public-project.$projectId'
@@ -29,6 +30,11 @@ import { Route as DashboardWorkspaceWorkspaceIdProjectProjectIdBoardRouteImport
import { Route as DashboardWorkspaceWorkspaceIdProjectProjectIdBacklogRouteImport } from './routes/dashboard/workspace/$workspaceId/project/$projectId/backlog'
import { Route as DashboardWorkspaceWorkspaceIdProjectProjectIdTaskTaskIdRouteImport } from './routes/dashboard/workspace/$workspaceId/project/$projectId/task/$taskId_'
+const TestErrorRoute = TestErrorRouteImport.update({
+ id: '/test-error',
+ path: '/test-error',
+ getParentRoute: () => rootRouteImport,
+} as any)
const DashboardRoute = DashboardRouteImport.update({
id: '/dashboard',
path: '/dashboard',
@@ -140,6 +146,7 @@ const DashboardWorkspaceWorkspaceIdProjectProjectIdTaskTaskIdRoute =
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/dashboard': typeof DashboardRouteWithChildren
+ '/test-error': typeof TestErrorRoute
'/auth/sign-in': typeof AuthSignInRoute
'/auth/sign-up': typeof AuthSignUpRoute
'/dashboard/$': typeof DashboardSplatRoute
@@ -161,6 +168,7 @@ export interface FileRoutesByFullPath {
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/dashboard': typeof DashboardRouteWithChildren
+ '/test-error': typeof TestErrorRoute
'/auth/sign-in': typeof AuthSignInRoute
'/auth/sign-up': typeof AuthSignUpRoute
'/dashboard/$': typeof DashboardSplatRoute
@@ -182,6 +190,7 @@ export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
'/dashboard': typeof DashboardRouteWithChildren
+ '/test-error': typeof TestErrorRoute
'/auth/sign-in': typeof AuthSignInRoute
'/auth/sign-up': typeof AuthSignUpRoute
'/dashboard/$': typeof DashboardSplatRoute
@@ -205,6 +214,7 @@ export interface FileRouteTypes {
fullPaths:
| '/'
| '/dashboard'
+ | '/test-error'
| '/auth/sign-in'
| '/auth/sign-up'
| '/dashboard/$'
@@ -226,6 +236,7 @@ export interface FileRouteTypes {
to:
| '/'
| '/dashboard'
+ | '/test-error'
| '/auth/sign-in'
| '/auth/sign-up'
| '/dashboard/$'
@@ -246,6 +257,7 @@ export interface FileRouteTypes {
| '__root__'
| '/'
| '/dashboard'
+ | '/test-error'
| '/auth/sign-in'
| '/auth/sign-up'
| '/dashboard/$'
@@ -268,6 +280,7 @@ export interface FileRouteTypes {
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
DashboardRoute: typeof DashboardRouteWithChildren
+ TestErrorRoute: typeof TestErrorRoute
AuthSignInRoute: typeof AuthSignInRoute
AuthSignUpRoute: typeof AuthSignUpRoute
PublicProjectProjectIdRoute: typeof PublicProjectProjectIdRoute
@@ -275,6 +288,13 @@ export interface RootRouteChildren {
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
+ '/test-error': {
+ id: '/test-error'
+ path: '/test-error'
+ fullPath: '/test-error'
+ preLoaderRoute: typeof TestErrorRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/dashboard': {
id: '/dashboard'
path: '/dashboard'
@@ -483,6 +503,7 @@ const DashboardRouteWithChildren = DashboardRoute._addFileChildren(
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
DashboardRoute: DashboardRouteWithChildren,
+ TestErrorRoute: TestErrorRoute,
AuthSignInRoute: AuthSignInRoute,
AuthSignUpRoute: AuthSignUpRoute,
PublicProjectProjectIdRoute: PublicProjectProjectIdRoute,
diff --git a/apps/web/src/routes/test-error.tsx b/apps/web/src/routes/test-error.tsx
new file mode 100644
index 000000000..bdf9535ed
--- /dev/null
+++ b/apps/web/src/routes/test-error.tsx
@@ -0,0 +1,14 @@
+import { ErrorTest } from "@/components/ui/error-test";
+import { createFileRoute } from "@tanstack/react-router";
+
+export const Route = createFileRoute("/test-error")({
+ component: TestErrorComponent,
+});
+
+function TestErrorComponent() {
+ return (
+ <div className="min-h-screen bg-zinc-50 dark:bg-zinc-900">
+ <ErrorTest />
+ </div>
+ );
+}
diff --git a/packages/libs/src/hono.ts b/packages/libs/src/hono.ts
index 6bb860183..1d7cd17ca 100644
--- a/packages/libs/src/hono.ts
+++ b/packages/libs/src/hono.ts
@@ -4,7 +4,7 @@ import type { AppType } from "@kaneo/api";
import { hc } from "hono/client";
export const client = hc<AppType>(
- import.meta.env.VITE_API_URL || "http://localhost:1337",
+ import.meta.env.VITE_API_URL || "http://andrej.cxom:1337",
{
fetch: (input: RequestInfo | URL, init?: RequestInit) => {
return fetch(input, {
@@ -14,6 +14,15 @@ export const client = hc<AppType>(
"Content-Type": "application/json",
},
credentials: "include",
+ }).catch((error) => {
+ if (error instanceof TypeError && error.message.includes("fetch")) {
+ const apiUrl =
+ import.meta.env.VITE_API_URL || "http://localhost:1337";
+ throw new Error(
+ `Failed to connect to API server at ${apiUrl}. This might be due to CORS configuration issues or the server not running. Please check your environment variables and server status.`,
+ );
+ }
+ throw error;
});
},
},