Drupal Core: 8.3.7
DrupalGap: 8.x-1.0-alpha1

Opening the DrupalGap configuration page (admin/config/services/drupalgap) it's trying to do a test connection.
But it fails because the GET request is calling http://jdrupal/connect?_format=json instead of http://www.example.com/jdrupal/connect?_format=json
The full url returns the json file correctly.

Trying with version 8.x-2.x the test request via GET passes but some other POST requests fail.

So in both versions I never get to the administration section of drupalgap.

Do I have to adjust the base url somewhere?
Or what could be the problem?

Thanks
Mathias

Comments

mcmulman created an issue. See original summary.

mcmulman’s picture

Issue summary: View changes
StatusFileSize
new10.95 KB
mcmulman’s picture

Title: Testing connection fails because of missing base url » Drupalgap: testing connection fails because of missing base url
mcmulman’s picture

Title: Drupalgap: testing connection fails because of missing base url » DrupalGap: testing connection fails because of missing base url
Issue summary: View changes
tyler.frankenstein’s picture

Hello @mcmulman, thank you for reporting this. My apologies for the delay in response. In your DrupalGap folder, open the settings.js file and set the value for jDrupal.settings.sitePath to https://www.example.com , I need to improve the DrupalGap installation to auto set this value for developers, otherwise this problem will continue for other newcomers.

tyler.frankenstein’s picture

Drupal 8.4.0

Please disregard comment #5, I went in and reminded myself after a few months/years as to how this all works in Drupal 8...

We already have in place a mechanism for auto reporting the Drupal url to the jDrupal sitePath variable during the DrupalGap connection test on admin/config/services/drupalgap , take a look at the connection-test.js file in DrupalGap:

http://cgit.drupalcode.org/drupalgap/tree/js/connection-test.js?h=8.x-1.x

I'd recommend adding this the top of the connection-test.js file:

console.log(drupalSettings)

We're specifically looking for the value drupalSettings.path.baseUrl, which should be (AFAIK) provided automatically by Drupal.

What does your drupalSettings object look like in the console log?

mandarmbhagwat78’s picture

I am facing similar issue https://www.drupal.org/node/2917619

Drupal core: 8.4.0
DrupalGap: 8.x-1.0-alpha1

I found that DrupalGap SDK installation is missing.

Also in drupalgap/scripts/install file below code is commented which is not creating settings.js file.

#echo "Preparing the settings.js file..."
#/bin/cp default.settings.js settings.js
#/bin/sed -i -e "s/sitePath: ''/sitePath: '$PATH'/g" settings.js
#/bin/sed -i -e "s/[sitePath: '']\/$*.^|[sitePath: '$PATH']/\\&/g"

Also I still could not see below permissions:
1. Access GET on Content resource : Anonymous user, Authenticated user
2. Access POST on Content resource : Authenticated user
2. Access PATCH on Content resource : Authenticated user
2. Access DELETE on Content resource : Authenticated user

tyler.frankenstein’s picture

I found that DrupalGap SDK installation is missing.

At first I thought the DrupalGap Connection Test screen needed a full SDK install and a settings.js file and a properly set sitePath in it to run. But after reviewing the code, the DrupalGap Connection Test page gets the Drupal URL from the drupalSettings object and goes from there by just utilizing jDrupal to make a connection test. So the install script technically has nothing to do with the connection test page, as it was an old school attempt of mine to make the SDK installable with one terminal command.

For now, if you are using the SDK, just copy the default.settings.js file into a settings.js file then set the sitePath variable in the jDrupal.settings object.

Also I still could not see below permissions:

It sounds like those permissions have been removed upstream, I will need to update the DrupalGap docs.

zak.schlemmer’s picture

I am also experiencing this issue

drupal 8.4.0
dg 8.x-1.0-alpha1

when outputting drupalSettings to console log I see a baseURL value of "/"

Everything within the app works without issue, possibly due to the sitePath value being set within settings.js

tyler.frankenstein’s picture

@zak, are you on a localhost environment? If so, what's your full url to the Drupal 8 site?

On this connection test page in DrupalGap, there is no settings.js file being loaded, and instead we're attempting to dynamically determine the sitePath using the value of baseUrl within drupalSettings.path, see here: http://cgit.drupalcode.org/drupalgap/tree/js/connection-test.js?h=8.x-1.x

From recollection, the baseUrl contained the domain for me, but I will go and verify that now.

UPDATE: On https://demo.drupalgap.org/8/drupal/ (which is the URL to the Drupal 8 site that powers the DrupalGap 8 demo via a LAMP stack (via Ubuntu 16.04). The baseUrl is reported as /8/drupal/, and then jDrupal is able to make the GET call to https://demo.drupalgap.org/8/drupal/jdrupal/connect?_format=json .

I wonder what it is about other environments that are preventing the domain from being included in the GET call here..

tyler.frankenstein’s picture

Status: Active » Needs review

Please download the latest dev snapshot of this module to see if it resolves the issue. It should now work better on a variety of environments.

zak.schlemmer’s picture

I can confirm that has resolved the issue for me.
Thanks!

tyler.frankenstein’s picture

Status: Needs review » Fixed
mandarmbhagwat78’s picture

Thanks @tyler.frankenstein.....alpha2 version resolved the issue. :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tt12’s picture

I'm having same issue with 8.x-1.0-alpha4 and drupal 8.4.3. Drupal site is on pantheon.io hosting
sdk is intalled manually
settings.js in app folder - ok
sitepath is set.

On Connection test - not found error.
In Console i have 2 errors:
1 Failed to load resource: the server responded with a status of 404 (Not Found)
http://dev-sitename.pantheonsite.io/jdrupal/connect?_format=json
or
GET http://dev-sitename.pantheonsite.io/jdrupal/connect?_format=json 404 (Not Found)

2 Uncaught (in promise) Error: Not Found
at XMLHttpRequest.c.onload (js_B_wcdTihtWukzNG4i4_g8cu9Yt6-JBiqBVO3rgv9R0w.js:701)

But the Path seems to be good..
Do you see where can be the problem, please?

tt12’s picture

Version: 8.x-1.0-alpha1 » 8.x-1.0-alpha4
mandarmbhagwat78’s picture

StatusFileSize
new39.69 KB

Hi @tt12,

Did you enable "jQuery Connect" web service with required settings? Check attached screenshot for reference.

tt12’s picture

Hi @mandarmbhagwat79! Thank you very much - that resolved the problem!
(I just followed docs.drupalgap.org but zapped the readme file)