Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: backend url #132

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NEXT_PUBLIC_SERVER_URL=http://localhost:8080
NEXT_PUBLIC_WS_URL=ws://localhost:8080

MODEL_API_BASE_URL=https://dashscope.aliyuncs.com/api/v1/apps/

Expand Down
3 changes: 2 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# TODO 生产环境域名
NEXT_PUBLIC_SERVER_URL=http://localhost:8080
NEXT_PUBLIC_SERVER_URL=http://1.117.152.40:8080
NEXT_PUBLIC_WS_URL=ws://1.117.152.40:8080

MODEL_API_BASE_URL=https://dashscope.aliyuncs.com/api/v1/apps/

Expand Down
2 changes: 1 addition & 1 deletion src/app/cooperation/(router)/[room]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function searchUserByEmail() {
const token = JSON.parse(localStorage.getItem('ONLINE_EDIT_AUTH') ?? '')?.access_token;

try {
const response = await fetch(`http://localhost:8080/api/v1/user`, {
const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand Down
13 changes: 9 additions & 4 deletions src/components/cooperation/cooperationEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ export const CooperationEditor: React.FC<CooperationEditorProps> = ({ roomId, us
return;
}

const provider = new WebsocketProvider('ws://localhost:8080', 'collaborateDoc', ydoc, {
params: {
record_id: roomId,
const provider = new WebsocketProvider(
`${process.env.NEXT_PUBLIC_WS_URL}`,
'collaborateDoc',
ydoc,
{
params: {
record_id: roomId,
},
},
});
);
setProvider(provider);

return () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/create-coopertaion-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function CreateCoopertaionModal() {

const handleCreate = async () => {
// 发送 POST 请求
const response = await fetch('http://localhost:8080/api/v1/document/create', {
const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/api/v1/document/create`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
9 changes: 9 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"value": "same-origin"
}
]
},
{
"source": "/cooperation/:slug*",
"headers": [
{
"key": "Cross-Origin-Embedder-Policy",
"value": "unsafe-none"
}
]
}
]
}
Loading