Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewx24 committed Jan 10, 2025
1 parent 020e842 commit 5684b02
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
18 changes: 15 additions & 3 deletions frontend/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};
const nextConfig: NextConfig ={
reactStrictMode: true,
images: {
domains: ['localhost'],
},
async rewrites() {
return [
{
source: '/api/:path*',
destination: `${process.env.NEXT_PUBLIC_API_URL}/api/:path*`,
},
]
},
}


export default nextConfig;
26 changes: 26 additions & 0 deletions frontend/src/services/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const BASE_URL = process.env.NEXT_PUBLIC_API_URL

export class ApiService {
static async get<T>(endpoint: string): Promise<T> {
const response = await fetch(`${BASE_URL}${endpoint}`, {
headers: {
'Content-Type': 'application/json',
// Add authorization header if needed
},
})
if (!response.ok) throw new Error('Network response was not ok')
return response.json()
}

static async post<T, D>(endpoint: string, data: D): Promise<T> {
const response = await fetch(`${BASE_URL}${endpoint}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
if (!response.ok) throw new Error('Network response was not ok')
return response.json()
}
}

0 comments on commit 5684b02

Please sign in to comment.