Commit 56ef9dd8 authored by dhevanthareza's avatar dhevanthareza

beneri

parent 3894abc3
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
\ No newline at end of file
FROM php:8.1-apache
RUN docker-php-ext-install mysqli pdo pdo_mysql
RUN apt-get update -y && apt-get install -y libpng-dev zlib1g-dev
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install gd
RUN a2enmod rewrite
<VirtualHost *:80>
DocumentRoot /var/www/html/
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/html/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
This diff is collapsed.
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.23.0.2. Set the 'ServerName' directive globally to suppress this message
[Wed Jul 12 02:26:11.659900 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.57 (Debian) PHP/8.1.21 configured -- resuming normal operations
[Wed Jul 12 02:26:11.661364 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
[Wed Jul 12 06:45:51.402531 2023] [mpm_prefork:notice] [pid 1] AH00170: caught SIGWINCH, shutting down gracefully
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.23.0.2. Set the 'ServerName' directive globally to suppress this message
[Wed Jul 12 06:45:55.153126 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.57 (Debian) PHP/8.1.21 configured -- resuming normal operations
[Wed Jul 12 06:45:55.156668 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
......@@ -12,7 +12,7 @@ class ExpenseController extends Controller
{
$user = Auth::user();
$expenses = Expense::where('user_id', $user->id)->get();
$expenses = Expense::where('user_id', $user->id)->orderBy('id', 'DESC')->get();
return response()->json($expenses);
}
......
<?php
namespace App\Http\Middleware;
use Closure;
class CorsMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$headers = [
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, PATCH, DELETE',
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Max-Age' => '86400',
'Access-Control-Allow-Headers' => 'Content-Type, Authorization, X-Requested-With'
];
if ($request->isMethod('OPTIONS'))
{
return response()->json('{"method":"OPTIONS"}', 200, $headers);
}
$response = $next($request);
foreach($headers as $key => $value)
{
$response->header($key, $value);
}
return $response;
}
}
\ No newline at end of file
......@@ -79,6 +79,9 @@ $app->configure('app');
$app->routeMiddleware([
'auth' => App\Http\Middleware\Authenticate::class,
]);
$app->middleware([
App\Http\Middleware\CorsMiddleware::class
]);
/*
|--------------------------------------------------------------------------
......
version: '3.1'
services:
php-apache:
container_name: expense-api
build:
context: .
dockerfile: Dockerfile
ports:
- 4001:80
volumes:
- ./:/var/www/html/
- ./apache/conf/default.conf:/etc/apache2/sites-enabled/000-default.conf
- ./apache/logs:/var/log/apache2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment