From a61dcd7a4e0d4f4e07f7b6ea8825a4c01efbf623 Mon Sep 17 00:00:00 2001 From: Chris Quigley Date: Fri, 22 Nov 2024 12:19:34 -0500 Subject: [PATCH] fix: Resolve CORS errors in OpenAPI tab of Playground (#3263) ## Relevant issue(s) Resolves #2458 ## Description There was a bug in the Playground's OpenAPI tool. This tool would list the URL of the endpoints as localhost instead of 127.0.0.1 (which is what the startup Defradb message shows.) The result was that attempting to execute one of the queries returned a CORS error. This was a one-liner fix. I adjusted openapi.go to use `http://127.0.0.1:9181/api/v0` as a string literal for the URL, instead of `http://localhost:9181/api/v0` ## Tasks - [x] I made sure the code is well commented, particularly hard-to-understand areas. - [x] I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in nts, ## How has this been tested? The platform(s) on which this was tested: - Windows --- docs/website/references/http/openapi.json | 2 +- http/openapi.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/website/references/http/openapi.json b/docs/website/references/http/openapi.json index 03c6a6513d..1f28b84a92 100644 --- a/docs/website/references/http/openapi.json +++ b/docs/website/references/http/openapi.json @@ -2363,7 +2363,7 @@ "servers": [ { "description": "Local DefraDB instance", - "url": "http://localhost:9181/api/v0" + "url": "/api/v0" } ], "tags": [ diff --git a/http/openapi.go b/http/openapi.go index 850ce081f4..b217036182 100644 --- a/http/openapi.go +++ b/http/openapi.go @@ -111,7 +111,7 @@ func NewOpenAPISpec() (*openapi3.T, error) { Servers: openapi3.Servers{ &openapi3.Server{ Description: "Local DefraDB instance", - URL: "http://localhost:9181/api/v0", + URL: "/api/v0", }, }, ExternalDocs: &openapi3.ExternalDocs{