Skip to content

Commit

Permalink
add domain to env and setup fetch url & image path
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonWingerAir committed Jan 21, 2024
1 parent 344e147 commit ee920f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NUXT_APP_BASE_URL='/OPTIONAL_BASE_URL'
API_FETCH_BASE_URL=YOUR_DOMAIN/

EXTERNAL_API_KEY=YOUR_API_KEY
API_BASE_URL=YOUR_BASE_URL
4 changes: 1 addition & 3 deletions components/GameCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ const props = defineProps({
}
});
const config = useRuntimeConfig();
const imgPath = computed(() => props.game?.image.original_url != null ? `${config.public.imgBaseUrl}${props.game?.image.original_url}` : '/254x356-gamepad.png');
const imgPath = computed(() => props.game?.image.original_url != null ? props.game?.image.original_url : '/254x356-gamepad.png');
</script>

<style scoped>
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineNuxtConfig({
apiKey: process.env.EXTERNAL_API_KEY,
apiBaseUrl: process.env.API_BASE_URL,
public: {
imgBaseUrl: ''
fetchBaseUrl: process.env.API_FETCH_BASE_URL
}
}
})
5 changes: 4 additions & 1 deletion pages/games/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const route = useRoute();
const config = useRuntimeConfig();
const gameId = computed(() => route.params.id);
const gameUrl = `http://localhost:3000/api/games/${gameId.value}`;
const gameUrl = `${config.public.fetchBaseUrl}api/games/${gameId.value}`;
console.log(gameUrl);
const { data } = await useFetch<GameResults>(gameUrl);
Expand Down

0 comments on commit ee920f7

Please sign in to comment.