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,
|
||||
|
||||
Reference in New Issue
Block a user