Arjit commited on
Commit
bb19891
·
1 Parent(s): fb8d8c4

Fix: Add API proxy through Next.js rewrites for Hugging Face deployment

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -1
  2. lib/api.ts +3 -1
  3. next.config.ts +8 -0
Dockerfile CHANGED
@@ -13,7 +13,7 @@ RUN npm install
13
 
14
  # Force cache invalidation for source file changes
15
  # Increment this value to force Docker to rebuild from this point
16
- ARG CACHEBUST=6
17
 
18
  # Copy all necessary files for Next.js build
19
  # Source files copied BEFORE config to invalidate cache when they change
 
13
 
14
  # Force cache invalidation for source file changes
15
  # Increment this value to force Docker to rebuild from this point
16
+ ARG CACHEBUST=7
17
 
18
  # Copy all necessary files for Next.js build
19
  # Source files copied BEFORE config to invalidate cache when they change
lib/api.ts CHANGED
@@ -5,7 +5,9 @@
5
 
6
  import { DocumentResults, ProcessResponse } from '@/types';
7
 
8
- const API_BASE = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000';
 
 
9
 
10
  export interface UploadResponse {
11
  document_id: string;
 
5
 
6
  import { DocumentResults, ProcessResponse } from '@/types';
7
 
8
+ // Use empty string to make requests relative to current origin
9
+ // Next.js will proxy /api/* requests to the backend via rewrites
10
+ const API_BASE = process.env.NEXT_PUBLIC_API_URL || '';
11
 
12
  export interface UploadResponse {
13
  document_id: string;
next.config.ts CHANGED
@@ -2,6 +2,14 @@ import type { NextConfig } from 'next';
2
 
3
  const nextConfig: NextConfig = {
4
  reactStrictMode: true,
 
 
 
 
 
 
 
 
5
  };
6
 
7
  export default nextConfig;
 
2
 
3
  const nextConfig: NextConfig = {
4
  reactStrictMode: true,
5
+ async rewrites() {
6
+ return [
7
+ {
8
+ source: '/api/:path*',
9
+ destination: 'http://localhost:8000/api/:path*',
10
+ },
11
+ ];
12
+ },
13
  };
14
 
15
  export default nextConfig;