Skip to content

Commit f29c30c

Browse files
authored
[HOTFIX][FE]: Try properly render exceptions page (#296)
2 parents 8520d6d + 151ca70 commit f29c30c

File tree

2 files changed

+111
-61
lines changed

2 files changed

+111
-61
lines changed

README.md

+102-52
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ used of Flowbite library to maintain responsive and materialize interface. And p
2525
- On Linux use docker-compose and docker.io
2626
- [Node JS 20.11](https://nodejs.org/en)
2727
- [PHP 8.2.12](https://www.php.net/downloads.php)
28-
- [PostgreSQL 16.2](https://www.postgresql.org/)
28+
- [PostgreSQL 17.0](https://www.postgresql.org/)
2929
- [Postman](https://www.postman.com/)
3030

3131
---
@@ -80,7 +80,6 @@ used of Flowbite library to maintain responsive and materialize interface. And p
8080
```
8181
4. Configure Client Host
8282
```bash
83-
- docker compose exec hana-app-pdf sed -i "s/VITE_ADOBE_CLIENT_ID=xxxx/VITE_ADOBE_CLIENT_ID=YOUR_ADOBE_CLIENT_ID/" >> .env
8483
- docker compose exec hana-app-pdf echo "TELEGRAM_BOT_ID=YOUR_TELEGRAM_BOT_ID" >> .env
8584
- docker compose exec hana-app-pdf echo "TELEGRAM_CHAT_ID=YOUR_TELEGRAM_CHANNEL_ID" >> .env
8685
- docker compose exec hana-app-pdf chmod o+w /var/www/html/hanaci-pdf/storage/ -R
@@ -99,7 +98,31 @@ used of Flowbite library to maintain responsive and materialize interface. And p
9998
- docker compose exec hana-app-pdf sed -i 's|http://192.168.0.2|YOUR_BACKEND_URL:PORT|' public/build/assets/kao-logic-CHECK_LATEST_REVISION.js
10099
- docker compose exec hana-app-pdf sed -i 's|STATIC_CLIENT_ID|YOUR_ADOBE_CLIENT_ID|' public/build/assets/kao-logic-CHECK_LATEST_REVISION.js
101100
```
102-
6. Refresh page and done.
101+
6. Configure Min.io
102+
- Open minio console page, URL: http://YOUR_LOCAL_IP:9001
103+
- Go to administrator -> bucket
104+
- Create new bucket with name "hana-pdf"
105+
- Go to user -> access key
106+
- Create new access key
107+
- Check "Restrict beyond user policy"
108+
- Fill custom policy
109+
```bash
110+
{
111+
"Version": "2012-10-17",
112+
"Statement": [
113+
{
114+
"Effect": "Allow",
115+
"Action": ["s3:GetObject", "s3:ListBucket", "s3:PutObject"],
116+
"Resource": ["arn:aws:s3:::hana-pdf", "arn:aws:s3:::hana-pdf/*"]
117+
}
118+
]
119+
}
120+
```
121+
- Copy Access key into backend module environment "MINIO_ACCESS_KEY"
122+
- Copy Secret key into backend module environment "MINIO_SECRET_KEY"
123+
- Set name access key into "hana-pdf"
124+
- Create access key
125+
7. Refresh page and done.
103126

104127
---
105128

@@ -112,7 +135,6 @@ used of Flowbite library to maintain responsive and materialize interface. And p
112135
A. Copy **.env.example** file to **.env** and modify database credentials
113136

114137
```bash
115-
- VITE_ADOBE_CLIENT_ID="ADOBE_CLIENT_ID" [https://developer.adobe.com/document-services/docs/overview/pdf-embed-api/]
116138
- VITE_JWT_TOKEN="YOUR_CURRENT_BEARER_TOKEN" [Get it from Backend with route api/v1/auth/getToken]
117139
- TELEGRAM_BOT_ID="YOUR_TELEGRAM_BOT_ID" [https://telegram-bot-sdk.com/docs/getting-started/installation]
118140
- TELEGRAM_CHAT_ID="YOUR_TELEGRAM_CHANNEL_ID" [https://telegram-bot-sdk.com/docs/getting-started/installation]
@@ -135,52 +157,80 @@ used of Flowbite library to maintain responsive and materialize interface. And p
135157

136158
2. Clone the repository with branch \_\_dev/be/master [Backend Services]
137159

138-
A. Copy **.env.example** file to **.env** and modify database credentials
139-
140-
```bash
141-
- ASPOSE_CLOUD_CLIENT_ID="ASPOSE_CLOUD_CLIENT_ID" [https://dashboard.aspose.cloud/]
142-
- ASPOSE_CLOUD_TOKEN="ASPOSE_CLOUD_TOKEN" [https://dashboard.aspose.cloud/]
143-
- FTP_USERNAME="FTP_USERNAME" [https://dashboard.aspose.cloud/]
144-
- FTP_USERPASS="FTP_USERPASS" [https://dashboard.aspose.cloud/]
145-
- FTP_SERVER="FTP_SERVER" [https://dashboard.aspose.cloud/]
146-
- ILOVEPDF_ENC_KEY="ILOVEPDF_ENC_KEY" [Generate your hash key (Max. 25 digits)]
147-
- ILOVEPDF_PUBLIC_KEY="ILOVEPDF_PUBLIC_KEY" [https://developer.ilovepdf.com/]
148-
- ILOVEPDF_SECRET_KEY="ILOVEPDF_SECRET_KEY" [https://developer.ilovepdf.com/]
149-
- PDF_IMG_POOL="image"
150-
- PDF_BATCH="batch"
151-
- PDF_UPLOAD="upload"
152-
- PDF_DOWNLOAD="download"
153-
- PDF_POOL="pool"
154-
- TELEGRAM_BOT_ID="YOUR_TELEGRAM_BOT_ID" [https://telegram-bot-sdk.com/docs/getting-started/installation]
155-
- TELEGRAM_CHAT_ID="YOUR_TELEGRAM_CHANNEL_ID" [https://telegram-bot-sdk.com/docs/getting-started/installation]
156-
- HANA_UNIQUE_TOKEN="YOUR_SHA512_UNIQUE_TOKEN"
157-
```
158-
159-
B. Run the following command [Make sure to configure database connectivity before use migrate function]
160-
161-
```bash
162-
- composer install
163-
- php artisan key:generate
164-
- php artisan jwt:secret
165-
- php artisan storage:link
166-
```
167-
168-
C. Create new directory inside storage/app/public
169-
170-
- image
171-
- batch
172-
- upload
173-
- download
174-
- pool
175-
176-
D. Start to deploy
177-
178-
```bash
179-
- npm run dev -- --host
180-
- php artisan serve --host=localhost --port=80
181-
```
182-
183-
E. Configure apiUrl variable on resources/js/kao-logic.js to your considered BE address and port !
160+
- Copy **.env.example** file to **.env** and modify database credentials
161+
```bash
162+
- ASPOSE_CLOUD_CLIENT_ID="ASPOSE_CLOUD_CLIENT_ID" [https://dashboard.aspose.cloud/]
163+
- ASPOSE_CLOUD_TOKEN="ASPOSE_CLOUD_TOKEN" [https://dashboard.aspose.cloud/]
164+
- FTP_USERNAME="FTP_USERNAME" [https://dashboard.aspose.cloud/]
165+
- FTP_USERPASS="FTP_USERPASS" [https://dashboard.aspose.cloud/]
166+
- FTP_SERVER="FTP_SERVER" [https://dashboard.aspose.cloud/]
167+
- ILOVEPDF_ENC_KEY="ILOVEPDF_ENC_KEY" [Generate your hash key (Max. 25 digits)]
168+
- ILOVEPDF_PUBLIC_KEY="ILOVEPDF_PUBLIC_KEY" [https://developer.ilovepdf.com/]
169+
- ILOVEPDF_SECRET_KEY="ILOVEPDF_SECRET_KEY" [https://developer.ilovepdf.com/]
170+
- PDF_IMG_POOL="image"
171+
- PDF_BATCH="batch"
172+
- PDF_UPLOAD="upload"
173+
- PDF_DOWNLOAD="download"
174+
- PDF_POOL="pool"
175+
- TELEGRAM_BOT_ID="YOUR_TELEGRAM_BOT_ID" [https://telegram-bot-sdk.com/docs/getting-started/installation]
176+
- TELEGRAM_CHAT_ID="YOUR_TELEGRAM_CHANNEL_ID" [https://telegram-bot-sdk.com/docs/getting-started/installation]
177+
- HANA_UNIQUE_TOKEN="YOUR_SHA512_UNIQUE_TOKEN"
178+
- MINIO_ACCESS_KEY="YOUR_MINIO_ACCESS_KEY"
179+
- MINIO_SECRET_KEY="YOUR_MINIO_SECRET_KEY"
180+
- MINIO_ENDPOINT="YOUR_MINIO_ENDPOINT_URL"
181+
```
182+
- Run the following command [Make sure to configure database connectivity before use migrate function]
183+
```bash
184+
- composer install
185+
- php artisan key:generate
186+
- php artisan jwt:secret
187+
- php artisan storage:link
188+
```
189+
- Create new directory inside storage/app/public
190+
- image
191+
- batch
192+
- upload
193+
- download
194+
- pool
195+
- Configure REST API
196+
- Install Postman
197+
- Create a new HTTP request with POST format
198+
- URL: http://YOUR_LOCAL_IP:YOUR_LOCAL_PORT/api/v1/auth/getToken
199+
- Body: form-data
200+
201+
- password: YOUR_SHA512_UNIQUE_TOKEN
202+
- Send a POST request to get access token
203+
- Configure frontend credentials
204+
- Set adobeClientID -> YOUR_ADOBE_CLIENT_ID
205+
- Set apiUrl -> YOUR_BACKEND_URL
206+
- Set bearerToken -> response token
207+
- Configure Min.io
208+
- Open minio console page, URL: http://YOUR_LOCAL_IP:9001
209+
- Go to administrator -> bucket - Create new bucket with name "hana-pdf"
210+
- Go to user -> access key - Create new access key
211+
- Check "Restrict beyond user policy"
212+
- Fill custom policy
213+
```bash
214+
{
215+
"Version": "2012-10-17",
216+
"Statement": [
217+
{
218+
"Effect": "Allow",
219+
"Action": ["s3:GetObject", "s3:ListBucket", "s3:PutObject"],
220+
"Resource": ["arn:aws:s3:::hana-pdf", "arn:aws:s3:::hana-pdf/*"]
221+
}
222+
]
223+
}
224+
```
225+
- Copy Access key into backend module environment "MINIO_ACCESS_KEY"
226+
- Copy Secret key into backend module environment "MINIO_SECRET_KEY"
227+
- Set name access key into "hana-pdf"
228+
- Create access key
229+
- Start to deploy
230+
```bash
231+
- npm run dev -- --host
232+
- php artisan serve --host=localhost --port=80
233+
```
184234

185235
---
186236

@@ -190,9 +240,9 @@ used of Flowbite library to maintain responsive and materialize interface. And p
190240
- [DropzoneJS](https://www.dropzone.dev/)
191241
- [Flowbite](https://flowbite.com/)
192242
- [Laravel](https://laravel.com/)
193-
- [Minio](https://min.io/)
243+
- [Min.io](https://min.io/)
194244
- [Node JS](https://nodejs.org/en)
195-
- [Mozilla PDFJS](https://mozilla.github.io/pdf.js/)
245+
- [Mozilla PDF.JS](https://mozilla.github.io/pdf.js/)
196246
- [Tailwind CSS](https://tailwindcss.com/)
197247
- [Vite JS](https://vitejs.dev/)
198248

app/Exceptions/Handler.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function render($request, Throwable $exception)
8080
]);
8181
Log::error($message);
8282
}
83-
abort(403);
83+
return response()->view('errors.403', [], 403);
8484
} else if ($exception instanceof TokenMismatchException || ($exception instanceof HttpException && $exception->getStatusCode() == 419)) {
8585
$message = 'TokenMismatchException: ' . $exception->getMessage();
8686
Log::error($message);
@@ -89,15 +89,15 @@ public function render($request, Throwable $exception)
8989
'errReason' => $message,
9090
'errStatus' => 'TokenMismatchException'
9191
]);
92-
abort(401);
92+
return response()->view('errors.401', [], 401);
9393
} else if ($exception instanceof RouteNotFoundException) {
9494
$message = 'RouteNotFoundException: ' . $exception->getMessage();
9595
appLogModel::where('groupId', '=', $Muuid)
9696
->update([
9797
'errReason' => $message,
9898
'errStatus' => 'Route not found exception!'
9999
]);
100-
abort(404);
100+
return response()->view('errors.404', [], 404);
101101
} else if ($exception instanceof NotFoundHttpException || ($exception instanceof HttpException && $exception->getStatusCode() == 404)) {
102102
$message = 'NotFoundHttpException: ' . $exception->getMessage();
103103
Log::error($message);
@@ -106,7 +106,7 @@ public function render($request, Throwable $exception)
106106
'errReason' => $message,
107107
'errStatus' => '404 - Page not found'
108108
]);
109-
abort(404);
109+
return response()->view('errors.404', [], 404);
110110
} else if ($exception instanceof HttpException && $exception->getStatusCode() == 403) {
111111
$message = 'HTTPResponseException: ' . $exception->getMessage();
112112
Log::error($message);
@@ -115,7 +115,7 @@ public function render($request, Throwable $exception)
115115
'errReason' => $message,
116116
'errStatus' => '403 - Forbidden'
117117
]);
118-
abort(403);
118+
return response()->view('errors.403', [], 403);
119119
} else if ($exception instanceof HttpException && $exception->getStatusCode() == 419) {
120120
$message = 'HTTPResponseException: ' . $exception->getMessage();
121121
Log::error($message);
@@ -124,7 +124,7 @@ public function render($request, Throwable $exception)
124124
'errReason' => $message,
125125
'errStatus' => '419 - Page Expired'
126126
]);
127-
abort(419);
127+
return response()->view('errors.419', [], 419);
128128
} else if ($exception instanceof HttpException && $exception->getStatusCode() == 429) {
129129
$message = 'HTTPResponseException: ' . $exception->getMessage();
130130
Log::error($message);
@@ -133,7 +133,7 @@ public function render($request, Throwable $exception)
133133
'errReason' => $message,
134134
'errStatus' => '429 - Too Many Requests'
135135
]);
136-
abort(429);
136+
return response()->view('errors.429', [], 429);
137137
} else if ($exception instanceof HttpException && $exception->getStatusCode() == 500) {
138138
$message = 'HTTPResponseException: ' . $exception->getMessage();
139139
Log::error($message);
@@ -142,7 +142,7 @@ public function render($request, Throwable $exception)
142142
'errReason' => $message,
143143
'errStatus' => '500 - Internal Server Error'
144144
]);
145-
abort(500);
145+
return response()->view('errors.500', [], 500);
146146
} else if ($exception instanceof HttpException && $exception->getStatusCode() == 503) {
147147
$message = 'HTTPResponseException: ' . $exception->getMessage();
148148
Log::error($message);
@@ -151,7 +151,7 @@ public function render($request, Throwable $exception)
151151
'errReason' => $message,
152152
'errStatus' => '503 - Service Temporary Unavailable'
153153
]);
154-
abort(503);
154+
return response()->view('errors.503', [], 503);
155155
}
156156
return parent::render($request, $exception);
157157
}

0 commit comments

Comments
 (0)