Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Resolve CORS errors in OpenAPI tab of Playground #3263

Merged
merged 4 commits into from
Nov 22, 2024

Conversation

ChrisBQu
Copy link
Collaborator

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

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • 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

@ChrisBQu ChrisBQu added the bug Something isn't working label Nov 20, 2024
@ChrisBQu ChrisBQu requested a review from a team November 20, 2024 21:27
@ChrisBQu ChrisBQu self-assigned this Nov 20, 2024
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.01%. Comparing base (909c4af) to head (29948be).
Report is 8 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3263      +/-   ##
===========================================
+ Coverage    77.53%   78.01%   +0.48%     
===========================================
  Files          382      382              
  Lines        35263    35308      +45     
===========================================
+ Hits         27341    27544     +203     
+ Misses        6296     6127     -169     
- Partials      1626     1637      +11     
Flag Coverage Δ
all-tests 78.01% <100.00%> (+0.48%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
http/openapi.go 97.52% <100.00%> (ø)

... and 58 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 909c4af...29948be. Read the comment docs.

---- 🚨 Try these New Features:

@ChrisBQu ChrisBQu changed the title fix: resolve CORS errors in OpenAPI tab of Playground fix: Resolve CORS errors in OpenAPI tab of Playground Nov 20, 2024
@ChrisBQu ChrisBQu requested a review from fredcarle November 21, 2024 21:51
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, sorry for this back peddling.. Your initial simple fix was the closest to the actual change we should have done.

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for dealing with the flip flop.

On the bright side you got exposed to the middleware system 🙂

@ChrisBQu ChrisBQu merged commit a61dcd7 into sourcenetwork:develop Nov 22, 2024
38 of 40 checks passed
ChrisBQu added a commit to ChrisBQu/defradb that referenced this pull request Feb 21, 2025
…3263)

## Relevant issue(s)

Resolves sourcenetwork#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CORS error when using Playground's OpenAPI
3 participants