-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetch APIのクレデンシャル指定方法をcredentialsからheader内のCookieに変更
Cloudflare WorkersはFetch APIの`credentials: 'include'`に対応していない。 そのため、リクエストに含まれるcookieをFetch APIのリクエストヘッダに直接追加することで解決。 また、+page.jsではなく+page.server.jsでないとcookiesを参照できない。
- Loading branch information
Showing
8 changed files
with
37 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
PUBLIC_API_ENDPOINT = /api | ||
PUBLIC_API_ENDPOINT = http://localhost:8787/api |
6 changes: 4 additions & 2 deletions
6
front/src/routes/(app)/+layout.js → front/src/routes/(app)/+layout.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
front/src/routes/(app)/register/+page.js → ...src/routes/(app)/register/+page.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
front/src/routes/(mail)/+layout.js → front/src/routes/(mail)/+layout.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}; | ||
} |