Cors updated
This commit is contained in:
@@ -14,8 +14,9 @@ COPY package-lock.json ./
|
|||||||
RUN npm install --ignore-scripts
|
RUN npm install --ignore-scripts
|
||||||
|
|
||||||
|
|
||||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
RUN addgroup -S appgroup && \
|
||||||
RUN chown -R appuser:appgroup /usr/src/app
|
adduser -S appuser -G appgroup && \
|
||||||
|
chown -R appuser:appgroup /usr/src/app
|
||||||
|
|
||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|||||||
@@ -23,34 +23,7 @@ import projectRouter from "./Routes/projectRoutes.ts";
|
|||||||
const app = express();
|
const app = express();
|
||||||
app.disable("x-powered-by");
|
app.disable("x-powered-by");
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const allowedOriginsDev = [
|
app.use(cors());
|
||||||
"http://localhost:3000",
|
|
||||||
"http://192.168.0.183:8200",
|
|
||||||
"http://192.168.0.101:8200",
|
|
||||||
"http://192.168.0.105:8200",
|
|
||||||
"http://192.168.0.134:8200",
|
|
||||||
];
|
|
||||||
const allowedOrigin =
|
|
||||||
process.env.NODE_ENV === "production"
|
|
||||||
? process.env.FRONTEND_ORIGIN_PROD
|
|
||||||
: allowedOriginsDev;
|
|
||||||
app.use(
|
|
||||||
cors({
|
|
||||||
origin: (origin, callback) => {
|
|
||||||
if (!origin) return callback(null, true);
|
|
||||||
if (Array.isArray(allowedOrigin) && allowedOrigin.includes(origin)) {
|
|
||||||
return callback(null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof allowedOrigin === "string" && origin === allowedOrigin) {
|
|
||||||
return callback(null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return callback(new Error("Not allowed by CORS"));
|
|
||||||
},
|
|
||||||
credentials: true,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.get("/", (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
res.send("Hello, I am Major-Dwinzo API!");
|
res.send("Hello, I am Major-Dwinzo API!");
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ export class FloatWidgetService {
|
|||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
if (existingFloatWidget) {
|
if (existingFloatWidget) {
|
||||||
const updateFloatWidget = await floatWidgetModel(
|
await floatWidgetModel(organization).findOneAndUpdate(
|
||||||
organization
|
|
||||||
).findOneAndUpdate(
|
|
||||||
{
|
{
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ export interface Camera extends Document {
|
|||||||
z: number;
|
z: number;
|
||||||
};
|
};
|
||||||
target: {
|
target: {
|
||||||
x: { type: Number; required: true };
|
x: { type: number; required: true };
|
||||||
y: { type: Number; required: true };
|
y: { type: number; required: true };
|
||||||
z: { type: Number; required: true };
|
z: { type: number; required: true };
|
||||||
};
|
};
|
||||||
rotation: {
|
rotation: {
|
||||||
x: { type: Number; required: true };
|
x: { type: number; required: true };
|
||||||
y: { type: Number; required: true };
|
y: { type: number; required: true };
|
||||||
z: { type: Number; required: true };
|
z: { type: number; required: true };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export interface ZoneSchema extends Document {
|
|||||||
zoneName: string;
|
zoneName: string;
|
||||||
createBy: mongoose.Types.ObjectId;
|
createBy: mongoose.Types.ObjectId;
|
||||||
points: [];
|
points: [];
|
||||||
layer: Number;
|
layer: number;
|
||||||
viewPortCenter: [];
|
viewPortCenter: [];
|
||||||
viewPortposition: [];
|
viewPortposition: [];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
|
|||||||
@@ -125,12 +125,12 @@ interface StorageEventSchema extends AssetEventSchema {
|
|||||||
point: StoragePointSchema;
|
point: StoragePointSchema;
|
||||||
}
|
}
|
||||||
interface IPointModel extends Document {
|
interface IPointModel extends Document {
|
||||||
modelUuid: String;
|
modelUuid: string;
|
||||||
modelName: String;
|
modelName: string;
|
||||||
position: String;
|
position: [number];
|
||||||
rotation: String;
|
rotation: [number];
|
||||||
state: String;
|
state: string;
|
||||||
productId: String;
|
productId: string;
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
|
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
|
||||||
speed: number;
|
speed: number;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ ARG NODE_VERSION=lts
|
|||||||
FROM node:${NODE_VERSION}-alpine AS development
|
FROM node:${NODE_VERSION}-alpine AS development
|
||||||
# Use production node environment by default.
|
# Use production node environment by default.
|
||||||
|
|
||||||
ENV NODE_ENV = development
|
ENV NODE_ENV=development
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import express from "express";
|
import express,{ Response, Request } from "express";
|
||||||
import { Response, Request } from "express";
|
|
||||||
import http from "http";
|
import http from "http";
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const createLineItems = async (data: any) => {
|
|||||||
export const updateLineItems = async (data: any) => {
|
export const updateLineItems = async (data: any) => {
|
||||||
const { organization, uuid, position } = data;
|
const { organization, uuid, position } = data;
|
||||||
try {
|
try {
|
||||||
const updateResult = await lineModel(organization).updateMany(
|
await lineModel(organization).updateMany(
|
||||||
{ "line.uuid": uuid },
|
{ "line.uuid": uuid },
|
||||||
{ $set: { "line.$.position": position } }
|
{ $set: { "line.$.position": position } }
|
||||||
);
|
);
|
||||||
@@ -86,7 +86,7 @@ export const deleteLayer = async (data: any) => {
|
|||||||
} else {
|
} else {
|
||||||
await lineModel(organization).deleteMany({ layer: layer });
|
await lineModel(organization).deleteMany({ layer: layer });
|
||||||
|
|
||||||
const updateResult = await lineModel(organization).updateMany(
|
await lineModel(organization).updateMany(
|
||||||
{ layer: { $gt: layer } },
|
{ layer: { $gt: layer } },
|
||||||
{ $inc: { layer: -1 } }
|
{ $inc: { layer: -1 } }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
|||||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
|
|
||||||
export const addPanel = async (data: any) => {
|
export const addPanel = async (data: any) => {
|
||||||
const { organization, zoneId, panelName, panelOrder } = data;
|
const { organization, zoneId, panelOrder } = data;
|
||||||
try {
|
try {
|
||||||
const findZone = await zoneSchema(organization).findOne({
|
const findZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
|
|||||||
Reference in New Issue
Block a user