lagoshny/ngx-hal-client

Error when root uri is set to relative path

Closed this issue · 2 comments

Hi there,

If we set the root uri as a relative path than it produces a "Invalid URL" error.

getRootUri(): string {
   return 'api/';
}

This would be useful sometimes if we are on the same server with back-end. On the other hand Angular's default XSRF protection does not work if the URL is absolute. Here You can see in the interceptor they have this

if (req.method === 'GET' || req.method === 'HEAD' || lcUrl.startsWith('http://') ||
        lcUrl.startsWith('https://')) {
      return next.handle(req);
    }

And documentation says this:

By default, an interceptor sends this header on all mutating requests (such as POST) to relative URLs

As a workaround I had my own interceptor to set XSRF token.

Hi @kbolukbas , thank you for the issue. I added support for the relative URLs in 1.2.3 version.

Hi @lagoshny ,
Thanks.
I will try it soon...