Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(server): should not listen on user defined host (#5622)

liuyi9fdbb3ac3de4
diff --git a/packages/backend/server/src/config/affine.ts b/packages/backend/server/src/config/affine.ts
index 7ae037507f..fa3a2f4e90 100644
--- a/packages/backend/server/src/config/affine.ts
+++ b/packages/backend/server/src/config/affine.ts
@@ -4,11 +4,7 @@ const env = process.env;
const node = AFFiNE.node;
// TODO(@forehalo): detail explained
-AFFiNE.host = 'localhost';
-AFFiNE.port = 3010;
-
if (node.prod) {
- AFFiNE.host = '0.0.0.0';
// Storage
if (env.R2_OBJECT_STORAGE_ACCOUNT_ID) {
AFFiNE.storage.providers.r2 = {
diff --git a/packages/backend/server/src/index.ts b/packages/backend/server/src/index.ts
index 8499eec2d4..19a01d349d 100644
--- a/packages/backend/server/src/index.ts
+++ b/packages/backend/server/src/index.ts
@@ -5,9 +5,10 @@ import './prelude';
import { createApp } from './app';
const app = await createApp();
-await app.listen(AFFiNE.port, AFFiNE.host);
+const listeningHost = AFFiNE.deploy ? '0.0.0.0' : 'localhost';
+await app.listen(AFFiNE.port, listeningHost);
console.log(
- `AFFiNE Server has been started on http://${AFFiNE.host}:${AFFiNE.port}.`
+ `AFFiNE Server has been started on http://${listeningHost}:${AFFiNE.port}.`
);
console.log(`And the public server should be recognized as ${AFFiNE.baseUrl}`);