最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Hocuspocus server websocket returns "OK" on next.js custom server - Stack Overflow

programmeradmin1浏览0评论

I am running tiptap with hocuspocus websocket for updating content to a database. This works fine locally but when I deploy it to my web hosting (where I run a custom next.js server) the web page returns nothing more than just a text “OK”.

This is my hocuspocus server:

import { Hocuspocus } from '@hocuspocus/server'

const onStoreDocument = async incomingData => {
    //store to database
}

const onLoadDocument = async incomingData => {
    //load from database
    return document
  }
    
export const server = new Hocuspocus({
    port: 1234,
    onStoreDocument,
    onLoadDocument,
    debounce: 5000
  })
}

Which I call from instrumentation.ts like this:

  export async function register() {
    const hocuspocusServer = await import("@/app/lib/hocuspocusServer")
    hocuspocusServer.server.listen()
  }

Locally I see my tiptap editor just as expected, but when built and uploaded to my web hosting I get the following result:

What am I doing wrong? I suspect the "OK" comes from the server.listen() but can't understand why it is doing this and especially when it isn't doing it locally / under development.

(Removing the hocuspocus server makes the tiptap editor run normally also on my web-hosting, but obviously without database connection)

发布评论

评论列表(0)

  1. 暂无评论