Skip to content

Commit

Permalink
fix: file path (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
noctera authored and luwol03 committed Jan 22, 2022
1 parent 40a464f commit 2270afe
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/Controllers/StaticPagesController.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const path = require('path');
const catchAsync = require('../utils/catchAsync');
const ApiError = require('../utils/ApiError.js');
const httpStatus = require('http-status');

const renderPageHandler = catchAsync(async (res, page) => {
const options = { root: process.cwd() };

// check if page should be rendered from a static file or should be redirected to another one
if (page.type === 'file') {
res.sendFile(page.location, options, (err) => {
res.sendFile(path.resolve(process.cwd(), page.location), (err) => {
if (err) {
throw new ApiError(httpStatus.NOT_FOUND, 'Page was not found');
}
Expand Down

0 comments on commit 2270afe

Please sign in to comment.