Skip to content

Commit

Permalink
feat: index redirect acts like spa returning 200 code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacek Jan Pietal committed Jul 27, 2022
1 parent 678e2c7 commit f545d76
Show file tree
Hide file tree
Showing 4 changed files with 341 additions and 334 deletions.
2 changes: 1 addition & 1 deletion dist/server/static-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function createFileReader(folder = "") {
const mime = (0, mime_types_1.lookup)(url) || "application/octet-stream";
const filename = (0, path_1.join)(folder, url);
if (!(0, fs_1.existsSync)(filename)) {
return { mime: "text/html", body: index, status: 301 };
return { mime: "text/html", body: index, status: 200 };
}
if ((0, fs_1.lstatSync)(filename).isDirectory()) {
return fileReader(`${url}/index.html`);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chef-core",
"version": "1.2.1",
"version": "1.3.0",
"description": "chef-js core functionalities",
"main": "index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -37,8 +37,8 @@
},
"devDependencies": {
"@types/mime-types": "^2.1.1",
"@types/node": "^18.0.3",
"jest": "^28.1.2",
"@types/node": "^18.6.1",
"jest": "^28.1.3",
"prettier": "^2.7.1",
"typescript": "^4.7.4"
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/static-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function createFileReader(
const filename: string = join(folder, url);

if (!existsSync(filename)) {
return { mime: "text/html", body: index, status: 301 };
return { mime: "text/html", body: index, status: 200 };
}

if (lstatSync(filename).isDirectory()) {
Expand Down
Loading

0 comments on commit f545d76

Please sign in to comment.