Cannot POST to worker service
My worker A (using Hono) has GET and POST endpoint like so:
In my worker B the code below successfully connect to worker A:
But when B tries to talk to A using POST:
it always error:
app.get('/test', (c) => {
return c.text('GET /test')
})
app.post('/test', (c) => {
return c.text('POST /test')
})app.get('/test', (c) => {
return c.text('GET /test')
})
app.post('/test', (c) => {
return c.text('POST /test')
})In my worker B the code below successfully connect to worker A:
app.get('/test', async (c) => {
return await c.env.WORKER_A.fetch(c.req) // 'GET /test'
})app.get('/test', async (c) => {
return await c.env.WORKER_A.fetch(c.req) // 'GET /test'
})But when B tries to talk to A using POST:
app.post('/test', async (c) => {
return await c.env.WORKER_A.fetch(c.req)
})app.post('/test', async (c) => {
return await c.env.WORKER_A.fetch(c.req)
})it always error:
Trace: TypeError: Cannot construct a Request with a Request object that has already been used.
at new Request (/Users/polt/aces-workers/auth-test/node_modules/undici/lib/fetch/request.js:488:15)
at new Request (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/core/src/standards/http.ts:393:13)
at upgradingFetch (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/web-sockets/src/fetch.ts:21:19)
at WebSocketPlugin.<anonymous> (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/core/src/standards/http.ts:891:21)
[TRUNCATED}Trace: TypeError: Cannot construct a Request with a Request object that has already been used.
at new Request (/Users/polt/aces-workers/auth-test/node_modules/undici/lib/fetch/request.js:488:15)
at new Request (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/core/src/standards/http.ts:393:13)
at upgradingFetch (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/web-sockets/src/fetch.ts:21:19)
at WebSocketPlugin.<anonymous> (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/core/src/standards/http.ts:891:21)
[TRUNCATED}