Open vbarbarosh opened 2 years ago
Current solution:
<?php
$file = __DIR__ . $_SERVER['PATH_INFO'];
if (is_file($file)) {
switch (preg_replace('/.*?([^.]+)$/', '$1', basename($file))) {
case 'jpg': $mime = 'image/jpeg'; break;
case 'jpeg': $mime = 'image/jpeg'; break;
case 'png': $mime = 'image/png'; break;
case 'svg': $mime = 'image/svg+xml'; break;
case 'gif': $mime = 'image/gif'; break;
case 'html': $mime = 'text/html'; break;
case 'md': $mime = 'text/plain'; break;
case 'css': $mime = 'text/css'; break;
case 'xml': $mime = 'text/xml'; break;
case 'js': $mime = 'text/javascript'; break;
case 'json': $mime = 'application/json'; break;
default: $mime = 'application/octet-stream'; break;
}
header("Content-Type: $mime");
header('Content-Length: ' . filesize($file));
flush();
readfile($file);
exit;
}
require_once __DIR__ . '/index-laravel.php';
It turns out that all requests are passed to the front controller. What about static files? I found no way to instruct nginx to serve them. Seems https://github.com/GoogleCloudPlatform/buildpacks/blob/main/pkg/nginx/nginx.go is responsible for making nginx.conf file.
This is how I built my app for GAE: