Initial Commit

This commit is contained in:
2023-07-10 10:17:17 +07:00
commit 48d1d02925
81 changed files with 24380 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
const { createServer } = require("@vue-storefront/middleware");
const { integrations } = require("./middleware.config");
const cors = require("cors");
(async () => {
const app = await createServer({ integrations });
const host = process.argv[2] ?? "0.0.0.0";
const port = process.argv[3] ?? 8181;
const CORS_MIDDLEWARE_NAME = "corsMiddleware";
const corsMiddleware = app._router.stack.find(
(middleware) => middleware.name === CORS_MIDDLEWARE_NAME
);
corsMiddleware.handle = cors({
origin: [
"http://localhost:3000",
...(process.env.MIDDLEWARE_ALLOWED_ORIGINS?.split(",") ?? []),
],
credentials: true,
});
app.listen(port, host, () => {
console.log(`Middleware started: ${host}:${port}`);
});
})();