Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to domain source to stop redirection from aliases #483

Open
wants to merge 1 commit into
base: 8.x-1.x
Choose a base branch
from

Conversation

gheydon
Copy link

@gheydon gheydon commented Jul 2, 2019

The current default behaviour of Domain source is to direct to the primary domain even if you are on an alias of the current domain that needs to be redirected to.

This caused me huge problems with GraphQL doing a route lookup query

query {
  route(path: "/bar") {
    ... on InternalUrl {
      nodeContext {
        __typename
      }
    }
  }
}

So in the example of using a primary domain of foo.com and the a graphql domain of api.foo.com and the Domain source it will try to redirect.

@agentrickard
Copy link
Owner

I do not understand the problem as currently explained.

Can you please provide more detail.

@gheydon
Copy link
Author

gheydon commented Jul 14, 2019

Basically if you have a situation when you have a domain and aliases of that domain, Domain source will redirect to the domain to primary domain even if you are on the alias of the domain.

eg. I have a primary domain https://foo.com and an alias https://bar.com of the primary domain. If you have a node node/1 with the domain source pointing to the primary domain. This means that on the primary domain the reference to the node will always be absolute https://foo.com/node/1 and the same on the alias. If you go to https://bar.com/node/1 you will get redirected to https://foo.com/node/1 even though they are the same domain, except foo.com is the alias.

This is usually not a problem except for the unnecessary redirects but when using GraphQL some queries do not work unless you are on the base url for the domain. Which means you can't do things like use https://api.foo.com to do all your queries.

So adding in this additional config option on the Domain source means that you can reduce your redirects and in the case of GraphQL use an api domain to make any calls.

@agentrickard
Copy link
Owner

agentrickard commented Jul 15, 2019

I see. These aren't redirects, per se, (unless the alias is set to redirect to it's parent) but the link HREF is being rewritten.

I wonder if instead of this patch, we should set Domain Source to be alias-aware. It certainly should be, and I would expect that the 'environment' handling would account for that.

To make that work, the current logic in this PR is close, but not quite right, I think.

Is the essential request here "Allow API calls to ignore Domain Source?"

Even if we fix that, I don't think you can use api.foo.com for all queries, because it won't know how to handle content separation unless you're handling that outside the node access system (likely by using a query_alter hook).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants