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