Skip to content

Commit

Permalink
feat: 更新 README 和後端 CORS 設定
Browse files Browse the repository at this point in the history
  • Loading branch information
phillychi3 committed Dec 27, 2024
1 parent 08e469f commit 227984a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ Lithium Player 是一個現代化的多媒體播放應用程式,支援音樂
```sh
git clone https://github.com/cl0udlab/Lithium-player
cd lithium-player
vim docker-compose.yml # 修改compose文件
```

```yml
backend:
image: phillychi3/lithium-player-backend:latest
container_name: lithium-backend
volumes:
- backend:/app/data
- C:\Users\user\Music:/media # 前面換成自己的音樂目錄
ports:
- "8000:8000"
environment:
SQLIP: postgres
APP_URL: 前端的網址(如果有的話
networks:
- lithium-network
depends_on:
- postgres
```
```sh
docker-compose up -d
```

Expand Down
18 changes: 12 additions & 6 deletions backend/src/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from dotenv import load_dotenv

load_dotenv()
import os
from db import engine, SQLModel
from fastapi import FastAPI
import json
Expand Down Expand Up @@ -39,14 +41,18 @@ def ping():
app.include_router(setting_router)
logger.info("Server started")

cors = [
"http://localhost:5173",
"http://localhost:3000",
"https://localhost",
"http://localhost:80",
os.getenv("APP_URL"),
]
cors = [url for url in cors if url]

app.add_middleware(
CORSMiddleware,
allow_origins=[
"http://localhost:5173",
"http://localhost:3000",
"https://localhost",
"http://localhost:80",
],
allow_origins=cors,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand Down

0 comments on commit 227984a

Please sign in to comment.