Skip to content

Multiple domains for different ressources ? overriden httpconfig #61

@AlexandreBonaventure

Description

@AlexandreBonaventure

Hi,
Wondering how to manage multiple httpConfig for different ressource (eg: setting different domain url for different ressource ), I ended up working with two adapters, which I believe was the right way to achieve it.

But I was surprised httpConfig was overridden by registering two http adapters.

Repro: https://jsfiddle.net/alexandreBonaventure/9ue6v6qy/6/

Is there an another to achieve this, any workaround ?

Activity

changed the title [-]Multiple domain for different ressources ? overriden httpconfig[/-] [+]Multiple domains for different ressources ? overriden httpconfig[/+] on Nov 3, 2016
jmdobry

jmdobry commented on Dec 12, 2016

@jmdobry
Member

Instead of using httpConfig#baseURL, I would recommend the following:

store.registerAdapter('http2', new DSHttpAdapter({
   basePath: `host1/api`
}))
store.registerAdapter('http', new DSHttpAdapter({
  basePath: `host2/api`
}), { default: true });
rkingon

rkingon commented on Apr 12, 2018

@rkingon

@jmdobry i am trying to do the same and do it exactly as you mention above... my issue is that one API requires an auth token in the headers and the other doesn't. however- both adapters are sharing the httpConfig defaults. This is sending the apiKey to both adapters and one doesn't allow that header key which results in an error. Any recommendations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @jmdobry@rkingon@AlexandreBonaventure

        Issue actions

          Multiple domains for different ressources ? overriden httpconfig · Issue #61 · js-data/js-data-http