diff --git a/front/.env.development b/front/.env.development index 68579e0..57f76c7 100644 --- a/front/.env.development +++ b/front/.env.development @@ -1 +1 @@ -PUBLIC_API_ENDPOINT = /api \ No newline at end of file +PUBLIC_API_ENDPOINT = http://localhost:8787/api \ No newline at end of file diff --git a/front/src/routes/(app)/+layout.js b/front/src/routes/(app)/+layout.server.js similarity index 67% rename from front/src/routes/(app)/+layout.js rename to front/src/routes/(app)/+layout.server.js index 4205b8b..b39f158 100644 --- a/front/src/routes/(app)/+layout.js +++ b/front/src/routes/(app)/+layout.server.js @@ -1,9 +1,11 @@ import { redirect } from "@sveltejs/kit"; import { PUBLIC_API_ENDPOINT } from '$env/static/public'; -export const load = async ({ fetch }) => { +export const load = async ({ cookies, fetch }) => { const res = await fetch(`${PUBLIC_API_ENDPOINT}/v1/ping`, { - credentials: 'include' + headers: { + cookie: cookies.get('id') + } }); if (res.status === 200) { diff --git a/front/src/routes/(app)/register/+page.js b/front/src/routes/(app)/register/+page.server.js similarity index 56% rename from front/src/routes/(app)/register/+page.js rename to front/src/routes/(app)/register/+page.server.js index 8245968..b3ba3e9 100644 --- a/front/src/routes/(app)/register/+page.js +++ b/front/src/routes/(app)/register/+page.server.js @@ -1,9 +1,7 @@ import { PUBLIC_API_ENDPOINT } from '$env/static/public'; -export const load = async ({ fetch }) => { - const { status } = await fetch(`${PUBLIC_API_ENDPOINT}/auth/register`, { - credentials: 'include' - }).then(r=>r.json()); +export const load = async ({ cookies, fetch }) => { + const { status } = await fetch(`${PUBLIC_API_ENDPOINT}/auth/register`).then(r=>r.json()); return { status diff --git a/front/src/routes/(mail)/+layout.js b/front/src/routes/(mail)/+layout.server.js similarity index 69% rename from front/src/routes/(mail)/+layout.js rename to front/src/routes/(mail)/+layout.server.js index e8cbc1b..6b2ceaf 100644 --- a/front/src/routes/(mail)/+layout.js +++ b/front/src/routes/(mail)/+layout.server.js @@ -1,9 +1,11 @@ import { redirect } from "@sveltejs/kit"; import { PUBLIC_API_ENDPOINT } from '$env/static/public'; -export const load = async ({ fetch }) => { +export const load = async ({ cookies, fetch }) => { const res = await fetch(`${PUBLIC_API_ENDPOINT}/v1/ping`, { - credentials: 'include' + headers: { + cookie: cookies.get('id') + } }); if (res.status === 401) { diff --git a/front/src/routes/(mail)/i/inbox/+page.js b/front/src/routes/(mail)/i/inbox/+page.js deleted file mode 100644 index 225df5a..0000000 --- a/front/src/routes/(mail)/i/inbox/+page.js +++ /dev/null @@ -1,11 +0,0 @@ -import { PUBLIC_API_ENDPOINT as API } from '$env/static/public'; - -export const load = async ({ fetch }) => { - const messages = await fetch(`${API}/v1/messages`, { - credentials: 'include' - }).then(r=>r.json()); - - return { - messages - }; -} \ No newline at end of file diff --git a/front/src/routes/(mail)/i/inbox/+page.server.js b/front/src/routes/(mail)/i/inbox/+page.server.js new file mode 100644 index 0000000..0cb7e6c --- /dev/null +++ b/front/src/routes/(mail)/i/inbox/+page.server.js @@ -0,0 +1,13 @@ +import { PUBLIC_API_ENDPOINT } from '$env/static/public'; + +export const load = async ({ cookies, fetch }) => { + const messages = await fetch(`${PUBLIC_API_ENDPOINT}/v1/messages`, { + headers: { + cookie: cookies.get('id') + } + }).then(r=>r.json()); + + return { + messages + }; +} \ No newline at end of file diff --git a/front/src/routes/(mail)/i/message/[id]/+page.js b/front/src/routes/(mail)/i/message/[id]/+page.js deleted file mode 100644 index 28f9e80..0000000 --- a/front/src/routes/(mail)/i/message/[id]/+page.js +++ /dev/null @@ -1,11 +0,0 @@ -import { PUBLIC_API_ENDPOINT as API } from '$env/static/public'; - -export const load = async ({ fetch, params }) => { - const message = await fetch(`${API}/v1/message/${params.id}`, { - credentials: 'include' - }).then(r=>r.json()); - - return { - message - }; -} \ No newline at end of file diff --git a/front/src/routes/(mail)/i/message/[id]/+page.server.js b/front/src/routes/(mail)/i/message/[id]/+page.server.js new file mode 100644 index 0000000..2bdf460 --- /dev/null +++ b/front/src/routes/(mail)/i/message/[id]/+page.server.js @@ -0,0 +1,13 @@ +import { PUBLIC_API_ENDPOINT } from '$env/static/public'; + +export const load = async ({ cookies, fetch, params }) => { + const message = await fetch(`${PUBLIC_API_ENDPOINT}/v1/message/${params.id}`, { + headers: { + cookie: cookies.get('id') + } + }).then(r=>r.json()); + + return { + message + }; +} \ No newline at end of file