Skip to content

Commit

Permalink
make apiUrl mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
sharknoon committed May 5, 2024
1 parent d8b2db6 commit 77b7d64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions components/tools/OrderModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ function order() {
},
body: JSON.stringify(body),
};
if (runtimeConfig.public.apiUrl === undefined) {
return;
}
fetch(
`${runtimeConfig.public.apiUrl}/cart/${cartCookie.value}/add`,
requestOptions,
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default defineNuxtConfig({
css: ["bootstrap/dist/css/bootstrap.min.css", "/assets/main.css"],
runtimeConfig: {
public: {
apiUrl: process.env.PIXINA_API_URL || "https://pixina.app/api/v1/progress",
apiUrl: process.env.PIXINA_API_URL,
pixelhobbTileId:
parseInt(process.env.PIXINA_PIXELHOBBY_TILE_ID ?? "") || 35007450218648,
},
Expand Down
4 changes: 4 additions & 0 deletions stores/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const useProgressStore = defineStore("progress", {
actions: {
async fetchProgress() {
const runtimeConfig = useRuntimeConfig();
if (!runtimeConfig.public.apiUrl) {
this.error = true;
return;
}
await fetch(runtimeConfig.public.apiUrl)
.then((response: Response) => {
if (response.status >= 200 && response.status <= 299) {
Expand Down

0 comments on commit 77b7d64

Please sign in to comment.