mirror of
https://github.com/KevinMidboe/planetposen-frontend.git
synced 2025-10-29 13:10:12 +00:00
Consistent build api url & updated base to /api/v1
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
import { dev } from '$app/environment';
|
||||
import { buildApiUrl } from './apiUrl';
|
||||
|
||||
export default async function requestSessionCookie() {
|
||||
let url = '/api';
|
||||
if (dev) {
|
||||
url = 'http://localhost:30010'.concat(url);
|
||||
}
|
||||
|
||||
const url = buildApiUrl('/api/v1');
|
||||
await fetch(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
<script lang="ts">
|
||||
import LinkArrow from '$lib/components/LinkArrow.svelte';
|
||||
import { buildApiUrl } from '$lib/utils/apiUrl';
|
||||
|
||||
export let isAdmin = false;
|
||||
|
||||
function logout() {
|
||||
let url = '/api/logout';
|
||||
if (window?.location?.href.includes('localhost')) {
|
||||
url = 'http://localhost:30010'.concat(url);
|
||||
}
|
||||
|
||||
const url = buildApiUrl('/api/v1/logout');
|
||||
fetch(url, { method: 'POST' }).then((resp) => {
|
||||
resp.status === 200 && window.location.reload();
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
import Input from '$lib/components/Input.svelte';
|
||||
import { buildApiUrl } from '$lib/utils/apiUrl';
|
||||
|
||||
let username: string;
|
||||
let password: string;
|
||||
@@ -20,11 +21,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
let url = '/api/login';
|
||||
if (window?.location?.href.includes('localhost')) {
|
||||
url = 'http://localhost:30010'.concat(url);
|
||||
}
|
||||
|
||||
const url = buildApiUrl('/api/v1/login');
|
||||
fetch(url, options)
|
||||
.then((resp) => {
|
||||
const { status } = resp;
|
||||
|
||||
@@ -52,7 +52,7 @@ function sitemapPages(): string {
|
||||
}
|
||||
|
||||
async function sitemapShopPages(): Promise<string> {
|
||||
const res = await fetch('/api/products');
|
||||
const res = await fetch('/api/v1/products');
|
||||
const productResponse: IProductsDTO = await res.json();
|
||||
|
||||
return productResponse?.products
|
||||
|
||||
@@ -35,9 +35,7 @@ a {
|
||||
text-decoration: none;
|
||||
|
||||
-webkit-transition: -webkit-transform 0.15s linear;
|
||||
transition: -webkit-transform 0.15s linear;
|
||||
transition: transform 0.15s linear;
|
||||
transition: transform 0.15s linear, -webkit-transform 0.15s linear;
|
||||
-webkit-transform-origin: 50% 80%;
|
||||
transform-origin: 50% 80%;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch }) => {
|
||||
const res = await fetch('/api/warehouse');
|
||||
const res = await fetch('/api/v1/warehouse');
|
||||
const warehouse = await res.json();
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user