Skip to content

Commit

Permalink
feat: backend url
Browse files Browse the repository at this point in the history
  • Loading branch information
coderz-w committed Oct 29, 2024
1 parent ee009d0 commit 9c09151
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
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"
}
]
}
]
}

0 comments on commit 9c09151

Please sign in to comment.