init: React frontend + PHP/Slim backend chat app
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use Slim\Factory\AppFactory;
|
||||
|
||||
require __DIR__ . '/../src/config.php';
|
||||
require __DIR__ . '/../src/db.php';
|
||||
require __DIR__ . '/../src/jwt.php';
|
||||
|
||||
$app = AppFactory::create();
|
||||
|
||||
// CORS for dev
|
||||
$app->add(function ($request, $handler) {
|
||||
$response = $handler->handle($request);
|
||||
return $response
|
||||
->withHeader('Access-Control-Allow-Origin', '*')
|
||||
->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
|
||||
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
||||
});
|
||||
|
||||
$app->addRoutingMiddleware();
|
||||
$app->addErrorMiddleware(true, true, true);
|
||||
|
||||
// Options handler
|
||||
$app->options('/{routes:.+}', function ($request, $response) {
|
||||
return $response;
|
||||
});
|
||||
|
||||
// Init DB
|
||||
getDb();
|
||||
|
||||
// Register routes
|
||||
require __DIR__ . '/../src/routes.php';
|
||||
|
||||
$app->run();
|
||||
Reference in New Issue
Block a user