Expand my Community achievements bar.

SOLVED

Graphql endpoint not working on dev publish behind a dispatcher

Avatar

Level 3

Hi guys,

 

I am having headaches trying to configure graphql endpoint to work on dev publish behind a dispatcher.

 

What i did:

-I configured graphql endpoint to be accessible by a certain group and also placed the required graphql settings in dispatcher. I am trying to send post request to graphql endpoint https://dev-publish-env/content/_cq_graphql/project/endpoint.json

with authorization header set as basic auth. This works in my local publish setup but in dev environment where we have dispatcher it doesn't.

 

Whats the problem:

-When i try to hit url from postman just like above with basic auth https://dev-publish-env/content/_cq_graphql/project/endpoint.json for some reason the authentication part isn't passing. But when we replace domain with an IP, then its working fine like this https://10.100.160.10/content/_cq_graphql/project/endpoint.json

Have in mind that if i disable permissions for the endpoint then hitting this url(which doesnt sent authorization header) https://dev-publish-env/content/_cq_graphql/project/endpoint.json  will now work.

 

I dont know how to fix this and its really confusing me.

I would really appreciate any help that i can get just so that i can maybe move in the right direction!

 

Thanks and hope you are all doing well,

Luka

1 Accepted Solution

Avatar

Correct answer by
Level 3

I was missing this in rewrite rules for persisted query to work: 

 

# Allow the dispatcher to be able to cache persisted queries - they need an extension for the cache file
RewriteCond %{REQUEST_URI} ^/graphql/execute.json
RewriteRule ^/(.*)$ /$1;.json [PT]

View solution in original post

3 Replies

Avatar

Employee Advisor

Hi @luka2 ,

Looks like your dispatcher filter is blocking the request. What error do you see while trying the API via dispatcher? Is it giving 404? Please check your dispatcher filters.any file and make sure the API is added to the allow list. Something like below:

# Allow GraphQL & preflight requests
# GraphQL also supports "GET" requests, if you intend to use "GET" add a rule in filters.any
/0060 { /type "allow" /method '(POST|OPTIONS)' /url "/content/_cq_graphql/*/endpoint.json" }

# GraphQL Persisted Queries & preflight requests
/0061 { /type "allow" /method '(GET|POST|OPTIONS)' /url "/graphql/execute.json*" }

 

Check the dispatcher log files and it will exactly tell you if the request to publish is blocked or if there is any other issue.

Avatar

Level 3

Hi @Anish-Sinha ,

Thanks so much for the reply!

I have those graphql configurations in place inside filters.any file.

So i managed to fix post request to graphql by adding Authorization header in the dispatcher clientheaders.any file, it was giving me 500 error.

 

But the get request to persisted query still isnt working. I am getting 404 error, the request is not even hitting publish server which means it stops at dispatcher. Seems like i something is blocking the persisted query get request even with allowing persisted query path in filters.any

 

 

Avatar

Correct answer by
Level 3

I was missing this in rewrite rules for persisted query to work: 

 

# Allow the dispatcher to be able to cache persisted queries - they need an extension for the cache file
RewriteCond %{REQUEST_URI} ^/graphql/execute.json
RewriteRule ^/(.*)$ /$1;.json [PT]