Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Get couldn't reach api while upgraded from 7 to 8 #1624

Closed
leonglkt opened this issue Jan 8, 2020 · 5 comments
Closed

Get couldn't reach api while upgraded from 7 to 8 #1624

leonglkt opened this issue Jan 8, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@leonglkt
Copy link

leonglkt commented Jan 8, 2020

After upgrade to 8.3.1, I always get couldn't reach api during login, directus didn't have any error message in the log, but I still can use api access the data of collections.
And I also try remove all existing config, browse directus 8 admin page, I get some introduction to create an new project, I follow the step to create project by an new database, the new project can login and work fine. but it is not possible to re-input the data into this new project.

@benhaynes benhaynes added the bug Something isn't working label Jan 8, 2020
@cdwmhcc
Copy link

cdwmhcc commented Jan 8, 2020

After upgrade to 8.3.1, I always get couldn't reach api during login, directus didn't have any error message in the log, but I still can use api access the data of collections.
And I also try remove all existing config, browse directus 8 admin page, I get some introduction to create an new project, I follow the step to create project by an new database, the new project can login and work fine. but it is not possible to re-input the data into this new project.

You need to use Phinx to upgrade your old database because the database structure of the new version has changed.

@binal-7span
Copy link
Contributor

@leonglkt - TBH, I didn't understand the exact issue. But what I understood is you're not able to login after upgrading the version. At the same time, I think the stand-alone APIs are working as you mentioned. Can you please provide more details like your PHP version, directus version [As we have almost 7 versions after 8.0.0], etc.

Screen recording of the issue will provide more help to resolve the issue.

@leonglkt
Copy link
Author

leonglkt commented Jan 22, 2020

OS: Centos 7.7.1908
Nginx : 1.16.1
PHP : 7.2.26
Directus : 8.3.1 / 8.4.0

Test case 1. Copy existing project config into a clean Directus(8.3.1), base on release note to modify the config(Directus 7 - 190927A), but I always got "Couldn't reach API" during login, but I still can use api access the data of collections. not error log found

Test case 2. Create an new project on a clean Directus(8.4.0). At this moment, I can login and work fine for this project, and then, I use mysqldump to backup exsiting project (Directus 7 - 190927A), and use mysql restore into the database of this new project, I got "Internal Server Error". I got follow error log
[2020-01-22 02:57:25] api[safpweb].ERROR: Error: Undefined class constant 'TYPE_USER_CREATED' in /data/directus-8.4.0/migrations/upgrades/20191123053252_update_directus_files_field.php:119 Stack trace: #0 /data/directus-8.4.0/vendor/robmorgan/phinx/src/Phinx/Migration/Manager/Environment.php(124): UpdateDirectusFilesField->change #1 /data/directus-8.4.0/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php(375): Phinx\Migration\Manager\Environment->executeMigration #2 /data/directus-8.4.0/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php(351): Phinx\Migration\Manager->executeMigration #3 /data/directus-8.4.0/src/core/Directus/Util/Installation/InstallerUtils.php(244): Phinx\Migration\Manager->migrate #4 /data/directus-8.4.0/src/core/Directus/Util/Installation/InstallerUtils.php(231): Directus\Util\Installation\InstallerUtils::runMigrationAndSeeder #5 /data/directus-8.4.0/src/core/Directus/Application/Http/Middleware/DatabaseMigrationMiddleware.php(13): Directus\Util\Installation\InstallerUtils::updateTables #6 [internal function]: Directus\Application\Http\Middleware\DatabaseMigrationMiddleware->__invoke #7 /data/directus-8.4.0/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array #8 [internal function]: Slim\DeferredCallable->__invoke #9 /data/directus-8.4.0/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func #10 /data/directus-8.4.0/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->Slim\{closure} #11 /data/directus-8.4.0/vendor/slim/slim/Slim/Route.php(268): Slim\Route->callMiddlewareStack #12 /data/directus-8.4.0/vendor/slim/slim/Slim/App.php(503): Slim\Route->run #13 /data/directus-8.4.0/src/core/Directus/Application/Http/Middleware/AbstractRateLimitMiddleware.php(34): Slim\App->__invoke #14 [internal function]: Directus\Application\Http\Middleware\AbstractRateLimitMiddleware->__invoke #15 /data/directus-8.4.0/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array #16 [internal function]: Slim\DeferredCallable->__invoke #17 /data/directus-8.4.0/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func #18 /data/directus-8.4.0/vendor/directus/proxy-detection/src/ProxyDetectionMiddleware.php(30): Slim\App->Slim\{closure} #19 /data/directus-8.4.0/src/core/Directus/Application/Http/Middleware/ProxyMiddleware.php(18): RKA\Middleware\ProxyDetectionMiddleware->__invoke #20 [internal function]: Directus\Application\Http\Middleware\ProxyMiddleware->__invoke #21 /data/directus-8.4.0/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array #22 [internal function]: Slim\DeferredCallable->__invoke #23 /data/directus-8.4.0/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func #24 /data/directus-8.4.0/vendor/akrabat/ip-address-middleware/src/IpAddress.php(113): Slim\App->Slim\{closure} #25 [internal function]: RKA\Middleware\IpAddress->__invoke #26 /data/directus-8.4.0/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array #27 [internal function]: Slim\DeferredCallable->__invoke #28 /data/directus-8.4.0/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func #29 /data/directus-8.4.0/src/core/Directus/Application/Http/Middleware/CorsMiddleware.php(71): Slim\App->Slim\{closure} #30 [internal function]: Directus\Application\Http\Middleware\CorsMiddleware->__invoke #31 /data/directus-8.4.0/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array #32 [internal function]: Slim\DeferredCallable->__invoke #33 /data/directus-8.4.0/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func #34 /data/directus-8.4.0/src/core/Directus/Application/Http/Middleware/ResponseCacheMiddleware.php(62): Slim\App->Slim\{closure} #35 [internal function]: Directus\Application\Http\Middleware\ResponseCacheMiddleware->__invoke #36 /data/directus-8.4.0/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array #37 [internal function]: Slim\DeferredCallable->__invoke #38 /data/directus-8.4.0/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func #39 /data/directus-8.4.0/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->Slim\{closure} #40 /data/directus-8.4.0/vendor/slim/slim/Slim/App.php(392): Slim\App->callMiddlewareStack #41 /data/directus-8.4.0/vendor/slim/slim/Slim/App.php(297): Slim\App->process #42 /data/directus-8.4.0/src/core/Directus/Application/Application.php(161): Slim\App->run #43 /data/directus-8.4.0/public/index.php(5): Directus\Application\Application->run [] []

@leonglkt
Copy link
Author

After follow #1653 change "TYPE_USER_CREATED" to "TYPE_OWNER", but login fail, the error message on page become "Couldn't Reach API", and not additonal error on error log.

file list on config
-rw-r--r-- 1 nginx nginx 2487 Jan 22 11:00 safpweb.php
-rw-r--r--. 1 nginx nginx 55 Jan 21 14:59 __api.json
-rw-rw-r--. 1 nginx nginx 6641 Jan 14 22:33 _example.php
content of safpweb.php
`<?php

return [
'database' => [
'type' => 'mysql',
'host' => 'myip',
'port' => myport,
'name' => 'myname',
'username' => 'myusername',
'password' => 'mypassword',
'engine' => 'InnoDB',
'charset' => 'utf8mb4',
// Remove 'host' above when using sockets
'socket' => '',
],

'cors' => [
    'enabled' => true,
    'origin' => array (

0 => '*',
),
'methods' => array (
0 => 'GET',
1 => 'POST',
2 => 'PUT',
3 => 'PATCH',
4 => 'DELETE',
5 => 'HEAD',
),
'headers' => array (
),
'exposed_headers' => array (
),
'max_age' => 600,
'credentials' => true,
],

'rate_limit' => [
    'enabled' => false,
    'limit' => 100,
    'interval' => 60,
    'adapter' => 'redis',
    'host' => '127.0.0.1',
    'port' => 6379,
    'timeout' => 10,
],

'storage' => [
    'adapter' => 'local',
    'root' => 'public/uploads/safpweb/originals',
    'root_url' => '/uploads/safpweb/originals',
    'thumb_root' => 'public/uploads/safpweb/generated',
    // 'key' => '',
    // 'secret' => '',
    // 'region' => '',
    // 'version' => '',
    // 'bucket' => '',
    // 'options' => '',
    // 'endpoint' => '',
    // 'proxy_downloads' => '',
],

'mail' => [
    'default' => [
        'transport' => 'sendmail',
        // 'sendmail' => '',
        // 'host' => '',
        // 'port' => '',
        // 'username' => '',
        // 'password' => '',
        // 'encryption' => '',
        'from' => '[email protected]'
    ],
],

'cache' => [
    'enabled' => false,
    'response_ttl' => 3600,
    'pool' => [
        // 'adapter' => '',
        // 'path' => '',
        // 'host' => '',
        // 'port' => '',
    ],
],

'auth' => [
    'secret_key' => 'eiQxQRZaR3Eu4qPIY71G7MDkxT9GoWsj',
    'public_key' => '03205db0-a155-4803-b4bd-bfac1d4434c1',
    'social_providers' => [
        // 'okta' => '',
        // 'github' => '',
        // 'facebook' => '',
        // 'google' => '',
        // 'twitter' => '',
    ],
],

'hooks' => [
    'actions' => [],
    'filters' => [],
],

'tableBlacklist' => [],

'env' => 'production',

'logger' => [
    'path' => '../logs',
],

];
`
Snap 2020-01-22 at 15 00 35
Snap 2020-01-22 at 15 01 41

@binal-7span
Copy link
Contributor

@leonglkt - #1669 will resolve your issue :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants