Skip to content

Commit

Permalink
fix: Fix rewrite api source
Browse files Browse the repository at this point in the history
  • Loading branch information
Najeong-Kim committed Aug 20, 2024
1 parent 8f402b1 commit 0da1858
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const nextConfig = {
async rewrites() {
return [
{
source: '/api/:path*',
source: '/weski/api/:path*',
destination: process.env.NEXT_PUBLIC_API_URL + '/:path*',
},
];
Expand Down
6 changes: 3 additions & 3 deletions src/shared/api/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ApiClient {
endpoint: string,
queryParams?: Record<string, string | number>
): Promise<TResult> {
const url = new URL('/api' + endpoint, window.location.origin);
const url = new URL('/weski/api' + endpoint, this.baseUrl);

if (queryParams) {
Object.entries(queryParams).forEach(([key, value]) => {
Expand All @@ -44,7 +44,7 @@ export class ApiClient {
endpoint: string,
body: TData
): Promise<TResult> {
const url = new URL('/api' + endpoint, window.location.origin);
const url = new URL('/weski/api' + endpoint, this.baseUrl);

const response = await fetch(url.toString(), {
method: 'POST',
Expand All @@ -58,4 +58,4 @@ export class ApiClient {
}
}

export const apiClient = new ApiClient('');
export const apiClient = new ApiClient(window.location.origin);

0 comments on commit 0da1858

Please sign in to comment.