supabase/supabase · info

Method ${method} Not Allowed

Error message

Method ${method} Not Allowed

What it means

HTTP 405 from the GitHub connections list route. Only GET is handled (returns `{ connections: [] }` in the local mock); any other verb returns `{ data: null, error: { message: 'Method ${method} Not Allowed' } }` with Allow: GET. Read-only listing of GitHub org/repo connections.

Source

Thrown at apps/studio/pages/api/platform/integrations/github/connections.ts:16

import { paths } from 'api-types'
import { NextApiRequest, NextApiResponse } from 'next'

import { apiWrapper } from '@/lib/api/apiWrapper'

export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)

async function handler(req: NextApiRequest, res: NextApiResponse) {
  const { method } = req

  switch (method) {
    case 'GET':
      return handleGet(req, res)
    default:
      res.setHeader('Allow', ['GET'])
      res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
  }
}

type ResponseData =
  paths['/platform/integrations/github/connections']['get']['responses']['200']['content']['application/json']

const handleGet = async (_req: NextApiRequest, res: NextApiResponse<ResponseData>) => {
  return res.status(200).json({ connections: [] })
}

View on GitHub (pinned to beee91b9c2)

Solutions

  1. GET this route to list existing connections only.
  2. Send add/remove operations to the real platform connection endpoint, not this read-only mock.
  3. Model the call as a query (useQuery), not a mutation, in the Studio data layer.
  4. Confirm the UI is targeting the correct writable URL for connect/disconnect.

Example fix

// before
await fetch('/api/platform/integrations/github/connections', { method: 'POST', body: JSON.stringify({ repo }) })

// after
const res = await fetch('/api/platform/integrations/github/connections')
const { connections } = await res.json()
Defensive patterns

Strategy: validation

Validate before calling

if (method.toUpperCase() !== 'GET') {
  throw new Error('github/connections is a GET list')
}

Type guard

type GithubConnectionsMethod = 'GET'
function isGithubConnectionsMethod(m: string): m is GithubConnectionsMethod {
  return m.toUpperCase() === 'GET'
}

Try / catch

const res = await fetch('/api/platform/integrations/github/connections')
if (res.status === 405) {
  throw new Error('Connections list is GET-only; add/remove on the platform endpoint')
}

Prevention

When it happens

Trigger: POST to add a connection, DELETE to remove one, or PATCH to update — all to /api/platform/integrations/github/connections.

Common situations: A 'Connect repository' dialog POSTing to the list endpoint instead of the platform connection endpoint; assuming the local mock persists writes; tests that POST to seed a connection.

Related errors


AI-assisted analysis of supabase/supabase@beee91b9c2 (2026-08-12). Data as JSON: /api/errors/e541b5e26d858ce4. Report an issue: GitHub.