refactoring: server actions => tmdb proxy
This commit is contained in:
1 parent
dfdfb79169
commit
97d55b24a1
13 files changed
+131
-113
No files matched your search
@@ -1,3 +1,7 @@
|
||||
import { isServer } from '@tanstack/react-query';
|
||||
|
||||
import { SITE_URL } from '@/env';
|
||||
|
||||
type Search = Record<string, string | number | boolean | null | undefined>;
|
||||
|
||||
class Http {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { isServer } from '@tanstack/react-query';
|
||||
|
||||
import Http from './Http';
|
||||
|
||||
const BASE =
|
||||
process.env.NEXT_PUBLIC_VERCEL_ENV === 'production'
|
||||
? process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL
|
||||
: process.env.NEXT_PUBLIC_VERCEL_URL;
|
||||
process.env.NEXT_VERCEL_ENV === 'production'
|
||||
? process.env.NEXT_VERCEL_PROJECT_PRODUCTION_URL
|
||||
: process.env.NEXT_VERCEL_URL;
|
||||
|
||||
const movieAdvisor = new Http(`${BASE?.startsWith('http') ? BASE : `https://${BASE}`}/api/tmdb`);
|
||||
const ROOT = isServer ? `${BASE?.startsWith('http') ? BASE : `https://${BASE}`}` : '';
|
||||
|
||||
const movieAdvisor = new Http(`${ROOT}/api/tmdb`);
|
||||
|
||||
export default movieAdvisor;
|
||||
@@ -1,7 +1,7 @@
|
||||
import { MOVIE_DB_TOKEN } from '@/env';
|
||||
import { MOVIE_DB_API_URL, MOVIE_DB_TOKEN } from '@/env';
|
||||
|
||||
import Http from './Http';
|
||||
|
||||
const theMovieDb = new Http('https://api.themoviedb.org/3', `Bearer ${MOVIE_DB_TOKEN}`);
|
||||
const theMovieDB = new Http(MOVIE_DB_API_URL, `Bearer ${MOVIE_DB_TOKEN}`);
|
||||
|
||||
export default theMovieDb;
|
||||
export default theMovieDB;
|
||||
Reference in new issue
Block a user