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

Could not authenticate when APP_DEBUG="false" (all apps) #567

Open
mobilex1122 opened this issue Jul 21, 2024 · 9 comments
Open

Could not authenticate when APP_DEBUG="false" (all apps) #567

mobilex1122 opened this issue Jul 21, 2024 · 9 comments
Labels

Comments

@mobilex1122
Copy link

mobilex1122 commented Jul 21, 2024

When I set .env variable APP_DEBUG to false it stops accepting any logins.

Everything works just fine with APP_DEBUG set to true.

My .env

APP_TENANT_ID=# ID
APP_PROJECT_KEY=# key
APP_URL="http://..."
APP_APPS_URL="http://..."
APP_ENV=prod
APP_DEBUG=false
APP_CONNECTION=# DB connection
APP_MAILER=# Mailer config
APP_MESSENGER="doctrine://default"
APP_MAIL_SENDER=# Sender
APP_MARKETPLACE="on"
@chriskapp
Copy link
Member

Could you show me the response of the XHR request of the login or also the error logs to see whether there is a specific error. In general in debug mode many caches are disabled.

@mobilex1122
Copy link
Author

I relised that the whole api crashes when debug is off so the webapp admin can't even contact the api. (I get white site indicating that PHP crashed mid generation)

@chriskapp
Copy link
Member

Ok, do you have any errors in the default PHP error log? You can also take a look at the log/app.log file. Maybe there are simply some file permission errors.

@mobilex1122
Copy link
Author

Here is the log
app.log

@chriskapp
Copy link
Member

So in your .env file thre is no APP_CONNECTION configured, you need to set there the fitting DB connection s. https://github.com/apioo/fusio/blob/master/.env#L7 the error also indicated this SQLSTATE[HY000] [2002] No such file or directory

@mobilex1122
Copy link
Author

I do have that set. I can normaly connect to the db in debug mode.

@mobilex1122
Copy link
Author

image
Here is the APP_CONNECTION variable (censured for security)

@Cale-Torino
Copy link

I recently had a similar issue on a shared hosting Linux dist I thought maybe it's a cache problem and I tried:

composer clear-cache
composer dump-autoload
composer dump-autoload -o

Because I had no access so the server SSH I could execute these via exec.

It's a scary way and make sure to delete this file after anyone uses it, but I needed a fast way to send commands.

<?php
$output=null;
$result=null;
//exec('composer clear-cache', $output, $result);
//exec('composer dump-autoload', $output, $result);
//exec('composer clearcache', $output, $result);
//exec('composer dump-autoload -o', $output, $result);
exec('composer', $output, $result);
echo json_encode(
    array(
        'data' =>
    array(
        'result' => $result,
    ),
    'reply' => $output
    )
);
?>

Still had an issue....

Then I remembered it's not Laravel perhaps it's something like: it points to .env.local for local etc.

Renaming the file did nothing....

Then opening the file to see if there was some weird string or something I noticed if you put a # comment on the same line the file fails to load.... switching to comments on the line above fixed the issue.... Wow what a frustrating thing but yeah just a simple error... easy to forget that

Posting this here for future reference.

Hopefully it helps someone in future.

Example of fix (in my case)

Fails to load # comment on same line

APP_TENANT_ID=""
APP_PROJECT_KEY="23b765c92fcd51c6772d4b00339c82ff"
APP_URL="http://127.0.0.1/fusio/public"
APP_APPS_URL="http://127.0.0.1/fusio/public/apps"
APP_ENV="prod" #dev or prod
APP_DEBUG="false" #true or false
APP_CONNECTION="pdo-mysql://root:@localhost/fusio_db"
APP_MAILER="native://default"
APP_MESSENGER="doctrine://default"
APP_MAIL_SENDER=""
SDKGEN_CLIENT_ID=""
SDKGEN_CLIENT_SECRET=""

Works # comment on line above

APP_TENANT_ID=""
APP_PROJECT_KEY="23b765c92fcd51c6772d4b00339c82ff"
APP_URL="http://127.0.0.1/fusio/public"
APP_APPS_URL="http://127.0.0.1/fusio/public/apps"
# dev or prod
APP_ENV="prod"
# true or false
APP_DEBUG="false"
APP_CONNECTION="pdo-mysql://root:@localhost/fusio_db"
APP_MAILER="native://default"
APP_MESSENGER="doctrine://default"
APP_MAIL_SENDER=""
SDKGEN_CLIENT_ID=""
SDKGEN_CLIENT_SECRET=""

@chriskapp
Copy link
Member

@Cale-Torino ok, I have also just added a commit to change the comment s. 155ec85

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

No branches or pull requests

3 participants