Skip to content

Commit 5d95e78

Browse files
committed
「React」の章の演習問題3の別解の内容を最新にアップデート
1 parent fb24ae7 commit 5d95e78

24 files changed

+3531
-1154
lines changed

docs/4-advanced/04-react/_samples/todo-database2/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/4-advanced/04-react/_samples/todo-database2/backend/.env.sample

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
# 別ドメインからFetch APIを用いてリクエストを送信可能にするために必要
2+
# WEB_ORIGINに設定したドメインからのリクエストのみを許可する
3+
# 参考:https://developer.mozilla.org/ja/docs/Web/HTTP/Guides/CORS
4+
WEB_ORIGIN="http://localhost:5173"
15
DATABASE_URL=""
2-
WEB_ORIGIN=http://localhost:5173
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
node_modules
2-
# Keep environment variables out of version control
3-
.env
4-
dist
1+
/node_modules
2+
/.env
3+
/generated/prisma
4+
/dist

docs/4-advanced/04-react/_samples/todo-database2/backend/main.ts renamed to docs/4-advanced/04-react/_samples/todo-database2/backend/main.mts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import express from "express";
22
import cors from "cors";
3+
import { PrismaClient } from "./generated/prisma/index.js";
4+
35
const app = express();
4-
import { PrismaClient } from "@prisma/client";
56
const client = new PrismaClient();
67

7-
app.use(cors({ origin: process.env["WEB_ORIGIN"] }));
8+
// 別ドメインからFetch APIを用いてリクエストを送信可能にするために必要
9+
// WEB_ORIGINに設定したドメインからのリクエストのみを許可する
10+
// 参考:https://developer.mozilla.org/ja/docs/Web/HTTP/Guides/CORS
11+
app.use(cors({ origin: process.env.WEB_ORIGIN }));
12+
813
app.use(express.json());
914

1015
app.get("/todos", async (request, response) => {

0 commit comments

Comments
 (0)