-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |