skip to Main Content

I have a project that was created on docker 4 containers
backend container
nginx container
database container
frontend container

The project is working correctly and the data that I pull from the backend is all json
Within the database I store urls for files that I store in backend/public
the question :
When I try to drag a file via Postman or Browser
Go to frontend/public/index.html
Instead of backend/public
What is the expected error?

I tried check any file from backend/public but it’s go to frontend/public

2

Answers


  1. Chosen as BEST ANSWER

    nginx config:

       location / {
        proxy_pass http://test-node:3000;
    }
    
    location /api/v1 {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    location ~ .php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass test-fpm:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
    

    backend route service:

        Route::prefix('api/v1')
            ->middleware(['auth:sanctum', 'api'])
            ->namespace($this->namespace)
            ->group(base_path('routes/api.php'));
    

  2. If the files are being directed to frontend/public instead of backend/public, it suggests that there might be a misconfiguration in your server or routing settings.

    1. Check your server routes and ensure that requests to files are being directed to the correct directory.
    2. Verify that your backend server is correctly configured to handle file requests from the backend/public directory
    3. Verify that the Nginx configuration points to the correct backend/public directory for serving files.
    4. Check the logs of your backend server and Nginx (if applicable) for any error messages or unexpected behavior when handling file requests.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search