Skip to content

compute: use authenticated endpoint via POST method

Administrator requested to merge rvt/compute-auth-endpoint into main

Created by: rvantonder

Sending requests to endpoints under /.api route require authentication when not requesting against Sourcegraph.com. Until now, all non-Sourcegraph.com instances could not run the compute block.

Due to limitations on SSE event spec and browsers, it's not possible to populate a origin header for GET requests. This means we can't do authenticated requests against /.api routes with GET. More on how this affects our current search stream API here: https://github.com/sourcegraph/sourcegraph/issues/29399

After attempting things (details here if you care), the path forward is to use a POST request (and expose a POST handler for this route), which will let me set the origin header, which will allow this endpoint to authenticate requests, so Compute blocks work on non-sourcegraph instances.

TL;DR: just stamp it, it makes things work.

Test plan

Tested manually for this experimental feature.

Merge request reports

Loading