Skip to content

Commit

Permalink
build: rewrites 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Si-off committed Jul 26, 2024
1 parent 78af28a commit 661ed4e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rewrites": [
{
"source": "/api/v1/:path*",
"destination": "http://58.233.84.92:9090/api/v1/:path*"
}
]
}
8 changes: 8 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
async rewrites() {
return [
{
source: '/api/v1/:path*',
destination: 'http://58.233.84.92:9090/api/v1/:path*',
},
];
},
images: {
remotePatterns: [
{
Expand Down
14 changes: 13 additions & 1 deletion src/lib/fetcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@ class Fetcher {
}
}

makeURL(endpoint: string): URL {
let url: URL;

if (typeof window === 'undefined') {
url = new URL(endpoint, this.baseURL as string);
} else {
url = new URL(endpoint, window.location.origin);
}

return url;
}

async get<T>(endpoint: string, params?: object, options?: FetcherRequestInit): Promise<T> {
const url = new URL(endpoint, this.baseURL);
const url = this.makeURL(endpoint);

if (params) {
url.search = qs.stringify(params);
Expand Down
8 changes: 0 additions & 8 deletions vercel.json

This file was deleted.

0 comments on commit 661ed4e

Please sign in to comment.