Skip to content

Commit

Permalink
fix: add env for base url for ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgevrgs committed Jun 14, 2024
1 parent 55d98e9 commit ba2a2da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { CelebritiesType } from '@libs/shared';

export async function getCelebritiesService(): Promise<CelebritiesType> {
const response = await fetch('/api/celebrities');
const response = await fetch(
new URL('/api/celebrities', process.env.NEXT_PUBLIC_PUBLIC_URL)
);

if (!response.ok) {
throw new Error(response.statusText);
Expand Down
20 changes: 13 additions & 7 deletions libs/frontend/src/application/services/update-vote.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ export async function updateVoteService({
}: UpdateVoteParams): Promise<CelebrityType> {
logger.info('Running updateVoteService', celebrityId, vote);

const response = await fetch(`/api/celebrities/${celebrityId}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ vote }),
});
const response = await fetch(
new URL(
`/api/celebrities/${celebrityId}`,
process.env.NEXT_PUBLIC_PUBLIC_URL
),
{
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ vote }),
}
);

if (!response.ok) {
throw new Error(response.statusText);
Expand Down

0 comments on commit ba2a2da

Please sign in to comment.