Skip to content

Commit 4a433ab

Browse files
committed
gRPC and HTTP to use same port with axum multiplexing
1 parent 6fced6d commit 4a433ab

14 files changed

Lines changed: 43 additions & 53 deletions

File tree

.gitlab/ci/build_app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
when: never
1212
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
1313
changes:
14-
- sapps/**/*
14+
- apps/**/*
1515
- .gitlab/ci/build_app.yml
1616

1717
app-web-image:

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/polycentric/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Comma-separated list of gRPC-web seed servers the client connects to
44
# on startup. The server's CDN URL is fetched dynamically via
55
# ServerService.GetInfo, so only the gRPC endpoint(s) need to be set.
6-
EXPO_PUBLIC_POLYCENTRIC_SEED_SERVERS=http://localhost:50051
6+
EXPO_PUBLIC_POLYCENTRIC_SEED_SERVERS=http://localhost:3000
77

88
# Host Metro and the app resolve `localhost` against. Set to your dev
99
# machine's LAN IP when running on a physical device/emulator.

apps/polycentric/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ RUN pnpm --filter polycentric-app --prod --legacy deploy /deploy
2424
FROM base AS runner
2525
WORKDIR /app
2626
ENV NODE_ENV=production
27+
ENV PORT=8080
2728

2829
COPY --from=build /deploy/node_modules ./node_modules
2930
COPY --from=build /deploy/package.json ./package.json
3031
COPY --from=build /app/apps/polycentric/dist ./dist
3132
COPY --from=build /app/apps/polycentric/server.js ./server.js
3233

33-
EXPOSE 3000
34+
EXPOSE 8080
3435
CMD ["node", "server.js"]

apps/polycentric/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const CLIENT_DIR = path.join(__dirname, 'dist', 'client');
77
const handler = createRequestHandler({
88
build: path.join(__dirname, 'dist', 'server'),
99
});
10-
const port = process.env.PORT || 3000;
10+
const port = process.env.PORT || 8080;
1111

1212
const MIME_TYPES = {
1313
'.html': 'text/html',

apps/polycentric/src/common/lib/polycentric-hooks/PolycentricProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ const DEFAULT_HOST = Platform.OS === 'android' ? '10.0.2.2' : 'localhost';
4343
/**
4444
* Comma-separated list of gRPC-web server URLs the client seeds
4545
* `client.servers` with. Read from `EXPO_PUBLIC_POLYCENTRIC_SEED_SERVERS`;
46-
* falls back to `http://<host>:50051` for local dev.
46+
* falls back to `http://<host>:3000` for local dev.
4747
*/
4848
export const DEFAULT_SEED_SERVERS: string[] = (() => {
4949
const raw = (process.env.EXPO_PUBLIC_POLYCENTRIC_SEED_SERVERS ?? '').trim();
5050
const parsed = raw
5151
.split(',')
5252
.map((s) => s.trim())
5353
.filter((s) => s.length > 0);
54-
return parsed.length > 0 ? parsed : [`http://${DEFAULT_HOST}:50051`];
54+
return parsed.length > 0 ? parsed : [`http://${DEFAULT_HOST}:3000`];
5555
})();
5656

5757
/** First seed server — used by identity onboarding helpers. */

packages/js-browser/examples/react/src/components/sync/sync-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const SyncPanel = () => {
102102
value={newServer}
103103
onChange={(e) => setNewServer(e.target.value)}
104104
onKeyDown={(e) => e.key === 'Enter' && addServer()}
105-
placeholder="http://localhost:50051"
105+
placeholder="http://localhost:3000"
106106
style={{ flex: 1 }}
107107
/>
108108
<button onClick={addServer}>Add</button>

packages/js-core/src/platform-interfaces/runtime-core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export interface IPolycentricCore {
7272
* Fetch events from a server via gRPC-web.
7373
*
7474
* # Arguments
75-
* * `server_url` - The base URL of the gRPC-web server (e.g. "http://localhost:50051")
75+
* * `server_url` - The base URL of the gRPC-web server (e.g. "http://localhost:3000")
7676
* * `limit` - Maximum number of events to fetch
7777
* * `identity` - Optional serialized Identity message bytes to filter by
7878
* * `stream_id` - Optional stream ID to filter by

packages/js-core/src/polycentric-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface PolycentricClientConfig {
4343
/**
4444
* gRPC-web URLs the client should start with. Used to seed
4545
* `client.servers` before `initialize()` fetches each server's
46-
* `ServerInfo`. Defaults to `['http://localhost:50051']`.
46+
* `ServerInfo`.
4747
*/
4848
seedServers?: string[];
4949
}
@@ -71,7 +71,7 @@ export class PolycentricClient {
7171
public currentKeyPair: KeyPair | null = null;
7272
/** The identity key the current key pair is actively using. Set by publishIdentity or claimIdentity. */
7373
public activeIdentityKey: string | null = null;
74-
public servers: string[] = ['http://localhost:50051'];
74+
public servers: string[] = ['http://localhost:3000'];
7575

7676
/** CDN URL per server, populated by `fetchServerInfo` during init. */
7777
private cdnUrlByServer = new Map<string, string>();

services/server/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2024"
77
# Workspace
88
entity = { path = "./entity" }
99
# 3rd Party
10-
axum = "0.8.8"
10+
axum = { version = "0.8.8", features = ["http2"] }
1111
ed25519-dalek = "2.2.0"
1212
log = "0.4"
1313
polycentric-common = { path = "../../packages/rs-common" }
@@ -22,5 +22,6 @@ tonic-prost = "*"
2222
tonic-reflection = "*"
2323
tonic-web = "*"
2424
tower-http = { version = "*", features = ["cors"] }
25+
tower-layer = "*"
2526
http = "*"
2627

0 commit comments

Comments
 (0)