Skip to content

Commit

Permalink
Improve error tracking on private network.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitlab Runner committed Aug 12, 2024
1 parent b11cf4f commit 95329e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This package follows standard semvar, `<major>.<minor>.<build>`. No breaking cha
* Add missing link to Tag display page.
* Replace `replaceState` with `pushState` so forwards and backwards navigation actually work.
* Add id and name for autocomplete options.
* Improve error on Access-Control-Allow-Private-Network.

## 2.1
* Add `x-locale` vendor extension to specify the locale of the spec.
Expand Down
6 changes: 5 additions & 1 deletion src/utils/spec-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export default async function ProcessSpec(specUrlOrObject, serverUrl = '') {

if (!jsonParsedSpec) {
if (errorToDisplay) {
throw Error(`Failed to resolve the spec: ${errorToDisplay}`);
if (inputSpecIsAUrl && specUrlOrObject.toString().match('localhost')) {
throw Error(`Cannot connect to your localhost running spec because your webserver is blocking requests. To the load the spec from ${specUrlOrObject.toString()}, return the following CORS header \`"Access-Control-Allow-Private-Network": "true"\`.`);
}
const message = `Failed to resolve the spec: ${errorToDisplay}`;
throw Error(message);
}
throw Error('SpecificationNotFound');
}
Expand Down

0 comments on commit 95329e9

Please sign in to comment.