IO-2935-Add-Enhanced-Websocket-Provider - fixes
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -8,7 +8,7 @@ const useSocket = (bodyshop) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (bodyshop && bodyshop.id) {
|
if (bodyshop && bodyshop.id) {
|
||||||
const endpoint = import.meta.env.PROD ? import.meta.env.VITE_APP_AXIOS_BASE_API_URL : "https://localhost:3000";
|
const endpoint = import.meta.env.PROD ? import.meta.env.VITE_APP_AXIOS_BASE_API_URL : "";
|
||||||
|
|
||||||
const socketInstance = SocketIO(endpoint, {
|
const socketInstance = SocketIO(endpoint, {
|
||||||
path: "/wss", // Ensure this matches the Vite proxy and backend path
|
path: "/wss", // Ensure this matches the Vite proxy and backend path
|
||||||
|
|||||||
@@ -23,17 +23,14 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(DmsContainer);
|
export default connect(mapStateToProps, mapDispatchToProps)(DmsContainer);
|
||||||
|
|
||||||
export const socket = SocketIO(
|
export const socket = SocketIO(import.meta.env.PROD ? import.meta.env.VITE_APP_AXIOS_BASE_API_URL : "", {
|
||||||
import.meta.env.PROD ? import.meta.env.VITE_APP_AXIOS_BASE_API_URL : "https://localhost:3000",
|
path: "/ws",
|
||||||
{
|
withCredentials: true,
|
||||||
path: "/ws",
|
auth: async (callback) => {
|
||||||
withCredentials: true,
|
const token = auth.currentUser && (await auth.currentUser.getIdToken());
|
||||||
auth: async (callback) => {
|
callback({ token });
|
||||||
const token = auth.currentUser && (await auth.currentUser.getIdToken());
|
|
||||||
callback({ token });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
|
||||||
export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
export default connect(mapStateToProps, mapDispatchToProps)(DmsContainer);
|
export default connect(mapStateToProps, mapDispatchToProps)(DmsContainer);
|
||||||
|
|
||||||
export const socket = SocketIO(
|
export const socket = SocketIO(
|
||||||
import.meta.env.PROD ? import.meta.env.VITE_APP_AXIOS_BASE_API_URL : "http://localhost:3000", // for dev testing,
|
import.meta.env.PROD ? import.meta.env.VITE_APP_AXIOS_BASE_API_URL : "", // for dev testing,
|
||||||
{
|
{
|
||||||
path: "/ws",
|
path: "/ws",
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
|
|||||||
16
server.js
16
server.js
@@ -11,6 +11,7 @@ const { createAdapter } = require("@socket.io/redis-adapter");
|
|||||||
const logger = require("./server/utils/logger");
|
const logger = require("./server/utils/logger");
|
||||||
const { redisSocketEvents } = require("./server/web-sockets/redisSocketEvents");
|
const { redisSocketEvents } = require("./server/web-sockets/redisSocketEvents");
|
||||||
const { instrument, RedisStore } = require("@socket.io/admin-ui");
|
const { instrument, RedisStore } = require("@socket.io/admin-ui");
|
||||||
|
|
||||||
const { isString, isEmpty } = require("lodash");
|
const { isString, isEmpty } = require("lodash");
|
||||||
const applyRedisHelpers = require("./server/utils/redisHelpers");
|
const applyRedisHelpers = require("./server/utils/redisHelpers");
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ const SOCKETIO_CORS_ORIGIN = [
|
|||||||
"https://test.imex.online",
|
"https://test.imex.online",
|
||||||
"https://www.test.imex.online",
|
"https://www.test.imex.online",
|
||||||
"http://localhost:3000",
|
"http://localhost:3000",
|
||||||
|
"https://localhost:3000",
|
||||||
"https://imex.online",
|
"https://imex.online",
|
||||||
"https://www.imex.online",
|
"https://www.imex.online",
|
||||||
"https://romeonline.io",
|
"https://romeonline.io",
|
||||||
@@ -46,7 +48,9 @@ const SOCKETIO_CORS_ORIGIN = [
|
|||||||
"https://old.imex.online",
|
"https://old.imex.online",
|
||||||
"https://www.old.imex.online",
|
"https://www.old.imex.online",
|
||||||
"https://wsadmin.imex.online",
|
"https://wsadmin.imex.online",
|
||||||
"https://www.wsadmin.imex.online"
|
"https://www.wsadmin.imex.online",
|
||||||
|
"http://localhost:3333",
|
||||||
|
"https://localhost:3333"
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,8 +62,13 @@ const applyMiddleware = (app) => {
|
|||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
app.use(bodyParser.json({ limit: "50mb" }));
|
app.use(bodyParser.json({ limit: "50mb" }));
|
||||||
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
|
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
|
||||||
app.use(cors({ credentials: true, exposedHeaders: ["set-cookie"] }));
|
app.use(
|
||||||
|
cors({
|
||||||
|
origin: SOCKETIO_CORS_ORIGIN,
|
||||||
|
credentials: true,
|
||||||
|
exposedHeaders: ["set-cookie"]
|
||||||
|
})
|
||||||
|
);
|
||||||
// Helper middleware
|
// Helper middleware
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
req.logger = logger;
|
req.logger = logger;
|
||||||
@@ -142,7 +151,6 @@ const applySocketIO = async (server, app) => {
|
|||||||
username: "admin",
|
username: "admin",
|
||||||
password: process.env.REDIS_ADMIN_PASS
|
password: process.env.REDIS_ADMIN_PASS
|
||||||
},
|
},
|
||||||
store: new RedisStore(pubClient),
|
|
||||||
mode: process.env.REDIS_ADMIN_MODE || "development"
|
mode: process.env.REDIS_ADMIN_MODE || "development"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ const applyRedisHelpers = (pubClient, app) => {
|
|||||||
// if (process.env.NODE_ENV === "development") {
|
// if (process.env.NODE_ENV === "development") {
|
||||||
// demoSessionData();
|
// demoSessionData();
|
||||||
// }
|
// }
|
||||||
|
// "th1s1sr3d1s" (BCrypt)
|
||||||
return api;
|
return api;
|
||||||
};
|
};
|
||||||
module.exports = applyRedisHelpers;
|
module.exports = applyRedisHelpers;
|
||||||
|
|||||||
Reference in New Issue
Block a user