0

Sorry for this long post I don't have any other way to describe it in short.

I have two Laravel application which are hosted in two subdomains of the same domain. One is

form.example.com another is dashboard.example.com.

The Dashboard app sends a http request to the Form app to get some JSON data. And the code it uses to send the request is like this:

$url = "https://form.example.com/api/v2/get/orders/" . urlencode($log->lastpull); $client = new \GuzzleHttp\Client(); $request = $client->request('GET', $url); $json = $request->getBody(); $objects = (json_decode($json)); 

Now the problem is that Dashboard app sometimes get a blank JSON or some error message in return from the Form app when this request is made.

However the same code works file in the localhost and when I look up the URL (https://form.example.com/api/v2/get/orders/) I get a valid JSON object. Which indicates that Form app is fine.

The error message I talked about I get from the Form app as a response for the HTTP request is this:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbl5qxvxfrl9tl.products' doesn't exist (SQL: select * from `products` order by `index` asc) 

The problem with this error message is that the database it mentions 'dbl5qxvxfrl9tl' belongs to the Dashboard app! The app which is making the request.

I have no idea why the Form app is looking for its table on the Dashboard app's database. It only occurs when I host the Dashboard app on my shared hosting's server. In localhost it works fine.

I tried to export the stack trace from the error page but for some reason it was not letting me to export. So I have saved the html page:

drive.google.com/file/d/1elbJhv4BpDNlxC2Ji_463dDLndjzjbm6/view?usp=sharing

(I have replaced the domain name in this html file for privacy reasons)

3
  • If these are two separate Laravel apps in different paths then you can also try running php artisan config:cache on both of them to generate a cache for the config so it doesn't read environment variables anymore (in case there's some cross-over) Commented Oct 11, 2021 at 14:29
  • @apokryfos Thank you so much for your response. This seemed to have solved the problem. I have another question. Do I have to run this command every time I update my .env from now? Commented Oct 11, 2021 at 14:57
  • Yes you do. What it does is it creates a cache of all the files in your config directory and calls all functions (including env) to generate that cache so when you change your .env you have to update the cache as well. Normally you wouldn't have to do this for local development and for production changing the .env is not something that happens too frequently Commented Oct 11, 2021 at 15:50

1 Answer 1

1

As user @apokryfos commented on the main post, solution to this problem is this:

If these are two separate Laravel apps in different paths then you can also try running php artisan config:cache on both of them to generate a cache for the config so it doesn't read environment variables anymore (in case there's some cross-over)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.