mirror of
https://github.com/JGH0/Todo-App-Backend.git
synced 2026-06-03 13:28:47 +02:00
Fix theme store connection
This commit is contained in:
@@ -98,18 +98,20 @@ $routes->group('api/v1', ['namespace' => 'App\Controllers\Api\V1', 'filter' => [
|
|||||||
});
|
});
|
||||||
$routes->get('/themes', 'ThemeStore::index');
|
$routes->get('/themes', 'ThemeStore::index');
|
||||||
$routes->options('/themes', static function () {
|
$routes->options('/themes', static function () {
|
||||||
header('Access-Control-Allow-Origin: http://localhost:5173');
|
$origin = service('request')->getHeaderLine('Origin') ?: '*';
|
||||||
|
header('Access-Control-Allow-Origin: ' . $origin);
|
||||||
header('Access-Control-Allow-Methods: GET, OPTIONS');
|
header('Access-Control-Allow-Methods: GET, OPTIONS');
|
||||||
header('Access-Control-Allow-Headers: Content-Type, Accept, Fetch');
|
header('Access-Control-Allow-Headers: Content-Type, Accept');
|
||||||
header('Access-Control-Allow-Credentials: true');
|
header('Vary: Origin');
|
||||||
return response()->setStatusCode(204);
|
return response()->setStatusCode(204);
|
||||||
});
|
});
|
||||||
$routes->post('/themes/upload', 'ThemeStore::upload');
|
$routes->post('/themes/upload', 'ThemeStore::upload');
|
||||||
$routes->options('/themes/upload', static function () {
|
$routes->options('/themes/upload', static function () {
|
||||||
header('Access-Control-Allow-Origin: http://localhost:5173');
|
$origin = service('request')->getHeaderLine('Origin') ?: '*';
|
||||||
|
header('Access-Control-Allow-Origin: ' . $origin);
|
||||||
header('Access-Control-Allow-Methods: POST, OPTIONS');
|
header('Access-Control-Allow-Methods: POST, OPTIONS');
|
||||||
header('Access-Control-Allow-Headers: Content-Type, Accept, Fetch');
|
header('Access-Control-Allow-Headers: Content-Type, Accept');
|
||||||
header('Access-Control-Allow-Credentials: true');
|
header('Vary: Origin');
|
||||||
return response()->setStatusCode(204);
|
return response()->setStatusCode(204);
|
||||||
});
|
});
|
||||||
$routes->get('/themes/preview/(:segment)', 'ThemeStore::preview/$1');
|
$routes->get('/themes/preview/(:segment)', 'ThemeStore::preview/$1');
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ class ThemeStore extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->request->isAJAX() || $this->request->hasHeader('Fetch') || str_contains($this->request->getHeaderLine('Accept'), 'application/json')) {
|
if ($this->request->isAJAX() || $this->request->hasHeader('Fetch') || str_contains($this->request->getHeaderLine('Accept'), 'application/json')) {
|
||||||
header('Access-Control-Allow-Origin: http://localhost:5173');
|
$origin = $this->request->getHeaderLine('Origin') ?: '*';
|
||||||
header('Access-Control-Allow-Credentials: true');
|
header('Access-Control-Allow-Origin: ' . $origin);
|
||||||
|
header('Vary: Origin');
|
||||||
return $this->response->setJSON($themes);
|
return $this->response->setJSON($themes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,8 +39,9 @@ class ThemeStore extends BaseController
|
|||||||
|
|
||||||
public function upload(): Response
|
public function upload(): Response
|
||||||
{
|
{
|
||||||
header('Access-Control-Allow-Origin: http://localhost:5173');
|
$origin = $this->request->getHeaderLine('Origin') ?: '*';
|
||||||
header('Access-Control-Allow-Credentials: true');
|
header('Access-Control-Allow-Origin: ' . $origin);
|
||||||
|
header('Vary: Origin');
|
||||||
|
|
||||||
$file = $this->request->getFile('theme_css');
|
$file = $this->request->getFile('theme_css');
|
||||||
$displayName = trim($this->request->getPost('display_name') ?? '');
|
$displayName = trim($this->request->getPost('display_name') ?? '');
|
||||||
|
|||||||
Reference in New Issue
Block a user