fix(api): align Phoenix stack with hub/NPM deploy (TLS edge, graphql-ws)
- tls-config: allow production HTTP when TERMINATE_TLS_AT_EDGE=1 (matches CT 7800) - websocket: disable perMessageDeflate on graphql-ws server (RSV1 / proxy compatibility) - server: remove unused @fastify/websocket (standalone ws + graphql-ws only) - package: drop @fastify/websocket dependency; refresh lockfile - .env.example: document HOST and TERMINATE_TLS_AT_EDGE for nginx-terminated TLS Made-with: Cursor
This commit is contained in:
@@ -39,14 +39,14 @@ export function getTLSConfig(): TLSConfig {
|
||||
|
||||
// Validate certificate files exist
|
||||
if (!fs.existsSync(certPath)) {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
if (process.env.NODE_ENV === 'production' && process.env.TERMINATE_TLS_AT_EDGE !== '1') {
|
||||
throw new Error(`TLS certificate not found: ${certPath}`)
|
||||
}
|
||||
logger.warn(`TLS certificate not found: ${certPath} - using HTTP only`)
|
||||
}
|
||||
|
||||
if (!fs.existsSync(keyPath)) {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
if (process.env.NODE_ENV === 'production' && process.env.TERMINATE_TLS_AT_EDGE !== '1') {
|
||||
throw new Error(`TLS key not found: ${keyPath}`)
|
||||
}
|
||||
logger.warn(`TLS key not found: ${keyPath} - using HTTP only`)
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dotenv/config'
|
||||
import Fastify from 'fastify'
|
||||
import { ApolloServer } from '@apollo/server'
|
||||
import { fastifyApolloDrainPlugin, fastifyApolloHandler } from '@as-integrations/fastify'
|
||||
import fastifyWebsocket from '@fastify/websocket'
|
||||
import { schema } from './schema'
|
||||
import { createContext } from './context'
|
||||
import { authMiddleware } from './middleware/auth'
|
||||
@@ -94,9 +93,6 @@ async function startServer() {
|
||||
|
||||
// Initialize blockchain service
|
||||
await initBlockchainService()
|
||||
|
||||
// Register WebSocket support
|
||||
await fastify.register(fastifyWebsocket)
|
||||
|
||||
// Start Apollo Server
|
||||
await apolloServer.start()
|
||||
|
||||
@@ -13,6 +13,7 @@ export function createWebSocketServer(httpServer: any, path: string) {
|
||||
const wss = new WebSocketServer({
|
||||
server: httpServer,
|
||||
path,
|
||||
perMessageDeflate: false,
|
||||
})
|
||||
|
||||
const serverCleanup = useServer(
|
||||
|
||||
Reference in New Issue
Block a user