diff --git a/apps/cf-page/index.html b/apps/cf-page/index.html
index e18bef0..f553c8a 100644
--- a/apps/cf-page/index.html
+++ b/apps/cf-page/index.html
@@ -3,7 +3,7 @@
- CfPage-test
+ Edge Tunnel VLESS CF
diff --git a/apps/cf-page/project.json b/apps/cf-page/project.json
index 4e8d7c8..2d43d7a 100644
--- a/apps/cf-page/project.json
+++ b/apps/cf-page/project.json
@@ -33,6 +33,13 @@
}
}
},
+ "serve-cf-page": {
+ "executor": "nx:run-commands",
+ "options": {
+ "command": "wrangler pages dev dist/apps/cf-page"
+ },
+ "dependsOn": ["^build"]
+ },
"test": {
"executor": "@nrwl/vite:test",
"outputs": ["{projectRoot}/coverage"],
diff --git a/apps/cf-page/src/main.tsx b/apps/cf-page/src/main.tsx
index 5b0ece9..f0d9210 100644
--- a/apps/cf-page/src/main.tsx
+++ b/apps/cf-page/src/main.tsx
@@ -1,13 +1,14 @@
import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';
-import App from './app/app';
+// import App from './app/app';
+import { EdgeApp } from 'edge-ui';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
-
+
);
diff --git a/apps/cf-page/tailwind.config.js b/apps/cf-page/tailwind.config.js
index d00839f..d0c1802 100644
--- a/apps/cf-page/tailwind.config.js
+++ b/apps/cf-page/tailwind.config.js
@@ -9,6 +9,7 @@ module.exports = {
'{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}'
),
...createGlobPatternsForDependencies(__dirname),
+ 'libs/edge-ui/src/lib/*.tsx',
],
theme: {
extend: {},
diff --git a/functions/_middleware.ts b/functions/_middleware.ts
index 40dd59b..2995d03 100644
--- a/functions/_middleware.ts
+++ b/functions/_middleware.ts
@@ -1,4 +1,6 @@
-const skipUrls = ["ws"];
+import { index401 } from './util';
+import { parse, stringify, validate } from 'uuid';
+const skipUrls = ['ws'];
async function errorHandling(context: EventContext) {
try {
@@ -9,18 +11,29 @@ async function errorHandling(context: EventContext) {
}
function authentication(context: EventContext) {
+ // if not set UUID, return 401 page
+ const userID = context.env['UUID'] || '';
+ let isVaildUser = validate(userID);
+ if (!isVaildUser) {
+ return new Response(index401, {
+ status: 401,
+ headers: {
+ 'content-type': 'text/html; charset=utf-8',
+ },
+ });
+ }
// skip authentication
- if (skipUrls.filter((url) => context.request.url.endsWith(url))) {
+ if (skipUrls.filter((url) => context.request.url.endsWith(url)).length) {
return context.next();
}
- const basicAuth = context.request.headers.get("Authorization") || "";
- const authString = basicAuth.split(" ")?.[1] || "";
- if (!atob(authString).includes("test")) {
+ const basicAuth = context.request.headers.get('Authorization') || '';
+ const authString = basicAuth.split(' ')?.[1] || '';
+ if (!atob(authString).includes(userID)) {
return new Response(``, {
status: 401,
headers: {
- "content-type": "text/html; charset=utf-8",
- "WWW-Authenticate": "Basic",
+ 'content-type': 'text/html; charset=utf-8',
+ 'WWW-Authenticate': 'Basic',
},
});
} else {
diff --git a/functions/hello.ts b/functions/hello.ts
index d931480..8ca76ba 100644
--- a/functions/hello.ts
+++ b/functions/hello.ts
@@ -3,5 +3,6 @@ interface Env {
}
export const onRequest: PagesFunction = async (context) => {
+ console.log('xxxxx', context.env);
return new Response(`Hello, world! ${context.request.url}`);
};
diff --git a/functions/setup.md b/functions/setup.md
new file mode 100644
index 0000000..8edab7c
--- /dev/null
+++ b/functions/setup.md
@@ -0,0 +1 @@
+for local env, create `.dev.vars` env file
diff --git a/functions/util.ts b/functions/util.ts
new file mode 100644
index 0000000..1ee4665
--- /dev/null
+++ b/functions/util.ts
@@ -0,0 +1,36 @@
+const index401 = `
+
+
+
+
+
+
+
+ 401 - UUID Not Valid
+
+
+
+
+ Not set valid UUID in Environment Variables.
+ Please use tool to generate and remember UUID or use this one
+
+ You must use same UUID for login this page after config valid UUID Environment Variables
+
+
+
+ Or maybe check below GIF
+
+
+
+
+`;
+
+export { index401 };