Skip to content

Commit

Permalink
fix: Resolve CORS errors in OpenAPI tab of Playground (#3263)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
ChrisBQu authored Nov 22, 2024
1 parent 6cacff1 commit a61dcd7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/website/references/http/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,7 @@
"servers": [
{
"description": "Local DefraDB instance",
"url": "http://localhost:9181/api/v0"
"url": "/api/v0"
}
],
"tags": [
Expand Down
2 changes: 1 addition & 1 deletion http/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit a61dcd7

Please sign in to comment.