Skip to content

Server errors don't display when using a same-origin endpoint URL. #41

@lucas42

Description

@lucas42

Steps to Reproduce

  1. Create a new Yasgui instance, where endpoint in the requestConfig provides a path on the same origin, rather than a full URL. For example:
import Yasgui from "@zazuko/yasgui";
import "@zazuko/yasgui/build/yasgui.min.css";

new Yasgui(document.getElementById("yasgui"), {
	requestConfig: { endpoint: "/sparql" },
	copyEndpointOnNewTab: false,
});
  1. Make a request through Yasgui which returns a HTTP error (eg a 5xx caused by a query timeout).

Expected Behaviour

The body of the erroring HTTP response to be shown in the UI, eg:

Image

Actual Behaviour

Nothing is show in the response section of the UI.

The following error is logged in the browser's console:

yasgui.min.js:2 Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL
    at yasgui.min.js:2:983497
    at f (yasgui.min.js:2:780774)
    at Generator.<anonymous> (yasgui.min.js:2:782097)
    at Generator.next (yasgui.min.js:2:781184)
    at yasgui.min.js:2:971919
    at new Promise (<anonymous>)
    at yasgui.min.js:2:971664
    at yasgui.min.js:2:983337
    at t.<anonymous> (yasgui.min.js:2:136769)
    at f (yasgui.min.js:2:780774)

Workaround

Add window.location.origin to the start of the endpoint.

import Yasgui from "@zazuko/yasgui";
import "@zazuko/yasgui/build/yasgui.min.css";

new Yasgui(document.getElementById("yasgui"), {
	requestConfig: { endpoint: window.location.origin+"/sparql" },
	copyEndpointOnNewTab: false,
});

It's unclear from the documentation whether the endpoint parameter is intended to only work for absolute URLs, or if relative ones are acceptable too. If there's meant to be a requirement for absolute URLs, I think it'd be more developer-friendly to check for that early on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions