-
Notifications
You must be signed in to change notification settings - Fork 629
Open
Description
Summary
When using the LINE Messaging API channel plugin with Moltworker, LINE webhooks fail with a 302 redirect because:
- Cloudflare Access blocks the incoming webhook request
- No public route exists in the Worker to proxy the webhook to the sandbox
Steps to Reproduce
- Deploy Moltworker with Cloudflare Access enabled
- Configure LINE channel in Clawdbot (
channels.line) - Set LINE webhook URL to
https://<worker>.workers.dev/line/webhook - Click "Verify" in LINE Developers Console
- Get
302 Founderror
Solution
1. Add public route in src/routes/public.ts
Add before export { publicRoutes };:
// POST /line/webhook - LINE webhook endpoint (no auth required)
publicRoutes.post('/line/webhook', async (c) => {
const sandbox = c.get('sandbox');
try {
const response = await sandbox.containerFetch(
new Request(`http://localhost:${MOLTBOT_PORT}/line/webhook`, {
method: 'POST',
headers: c.req.raw.headers,
body: c.req.raw.body,
}),
MOLTBOT_PORT
);
return new Response(response.body, {
status: response.status,
headers: response.headers,
});
} catch (err) {
console.error('[LINE] Webhook proxy error:', err);
return c.json({ error: 'Gateway not ready' }, 503);
}
});-
Create Cloudflare Access Bypass Application
-
Go to Cloudflare Zero Trust Dashboard
-
Access → Applications → Add application → Self-hosted
-
Set: • Application domain: .workers.dev
• Path: /line/webhook -
Add policy: • Action: Bypass
• Include: Everyone
Suggestion
Consider adding LINE webhook route to the default public.ts and documenting the Cloudflare Access bypass requirement in the README.
Metadata
Metadata
Assignees
Labels
No labels