realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Strip trailing slash off baseUrl

Open kraenhansen opened this issue 3 years ago • 1 comments

Goals

Making it easier to configure a custom baseUrl.

Expected Results

When constructing an app with a custom baseUrl it shouldn't matter if it has a trailing slash or not:

const app = new App({ baseUrl: "http://localhost:9090" });
const app = new App({ baseUrl: "http://localhost:9090/" });
//  this yeilds errors due to a double slash in urls

Actual Results

When a slash is accidentally added to the baseUrl errors like this occur (when using Realm Web):

Access to fetch at 'http://localhost:9090//api/client/v2.0/app/pholiota-vrozman-mtjhb/location' from origin 'http://localhost:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Version of Realm and Tooling

  • Realm JS SDK Version: Realm Web 1.2.1
  • Node or React Native: Node, React Native and Web.
  • Client OS & Version: N/A
  • Which debugger for React Native: None

kraenhansen avatar Apr 22 '21 09:04 kraenhansen

can I work on this please?

NextThread avatar Aug 20 '23 17:08 NextThread