create-jinmankn-app 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-jinmankn-app",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "create-jinmankn-app": "./bin/index.js"
@@ -0,0 +1,4 @@
1
+ # Netscape HTTP Cookie File
2
+ # https://curl.se/docs/http-cookies.html
3
+ # This file was generated by libcurl! Edit at your own risk.
4
+
@@ -13,12 +13,15 @@ const protectedRoutes = require('./routes/protectedRoutes');
13
13
 
14
14
  const app = express();
15
15
 
16
- app.use(
17
- cors({
18
- origin: 'http://localhost:5173',
19
- credentials: true,
20
- })
21
- );
16
+ app.set('trust proxy', 1);
17
+
18
+ const corsOptions = {
19
+ origin: 'http://localhost:5173',
20
+ credentials: true,
21
+ };
22
+
23
+ app.use(cors(corsOptions));
24
+ app.options('*', cors(corsOptions));
22
25
  app.use(express.json());
23
26
  app.use(
24
27
  session({
@@ -27,8 +30,8 @@ app.use(
27
30
  saveUninitialized: false,
28
31
  cookie: {
29
32
  httpOnly: true,
30
- secure: false,
31
- sameSite: 'none',
33
+ secure: process.env.NODE_ENV === 'production',
34
+ sameSite: 'lax',
32
35
  maxAge: 1000 * 60 * 60 * 24,
33
36
  },
34
37
  })
@@ -21,7 +21,7 @@ function DashboardLayout() {
21
21
  setUser(JSON.parse(storedUser));
22
22
  }
23
23
 
24
- axios.get('http://localhost:5006/api/auth/me', {
24
+ axios.get('/api/auth/me', {
25
25
  withCredentials: true,
26
26
  })
27
27
  .then((response) => {
@@ -37,7 +37,7 @@ function DashboardLayout() {
37
37
 
38
38
  const handleLogout = async () => {
39
39
  try {
40
- await axios.post('http://localhost:5006/api/auth/logout', null, {
40
+ await axios.post('/api/auth/logout', null, {
41
41
  withCredentials: true,
42
42
  });
43
43
  } catch (err) {
@@ -106,3 +106,4 @@ function DashboardLayout() {
106
106
 
107
107
  export default DashboardLayout;
108
108
 
109
+
@@ -1,11 +1,14 @@
1
1
  import { StrictMode } from 'react'
2
2
  import { createRoot } from 'react-dom/client'
3
+ import axios from 'axios'
3
4
  import './index.css'
4
5
  import App from './App.jsx'
5
6
 
7
+ axios.defaults.withCredentials = true
8
+
6
9
  createRoot(document.getElementById('root')).render(
7
10
  <StrictMode>
8
11
  <App />
9
12
  </StrictMode>,
10
13
  )
11
-
14
+
@@ -17,7 +17,7 @@ function CreateUser() {
17
17
  }
18
18
 
19
19
  axios
20
- .get('http://localhost:5006/api/auth/me', {
20
+ .get('/api/auth/me', {
21
21
  withCredentials: true,
22
22
  })
23
23
  .then((response) => {
@@ -33,7 +33,7 @@ function CreateUser() {
33
33
  if (!user || user.role !== 'admin') return;
34
34
 
35
35
  axios
36
- .get('http://localhost:5006/api/employees/list', {
36
+ .get('/api/employees/list', {
37
37
  withCredentials: true,
38
38
  })
39
39
  .then((response) => setEmployees(response.data))
@@ -59,7 +59,7 @@ function CreateUser() {
59
59
 
60
60
  try {
61
61
  const response = await axios.post(
62
- 'http://localhost:5006/api/auth/users',
62
+ '/api/auth/users',
63
63
  {
64
64
  employeeId: selectedEmployeeId,
65
65
  password,
@@ -147,3 +147,4 @@ function CreateUser() {
147
147
  }
148
148
 
149
149
  export default CreateUser;
150
+
@@ -9,9 +9,9 @@ function DashboardHome() {
9
9
 
10
10
  useEffect(() => {
11
11
  Promise.all([
12
- axios.get('http://localhost:5006/api/departments/list', { withCredentials: true }),
13
- axios.get('http://localhost:5006/api/employees/list', { withCredentials: true }),
14
- axios.get('http://localhost:5006/api/positions/list', { withCredentials: true }),
12
+ axios.get('/api/departments/list', { withCredentials: true }),
13
+ axios.get('/api/employees/list', { withCredentials: true }),
14
+ axios.get('/api/positions/list', { withCredentials: true }),
15
15
  ])
16
16
  .then(([deptRes, empRes, posRes]) => {
17
17
  setDepartments(deptRes.data);
@@ -55,3 +55,4 @@ function DashboardHome() {
55
55
 
56
56
  export default DashboardHome;
57
57
 
58
+
@@ -10,7 +10,7 @@ function Department() {
10
10
 
11
11
  const getDepartments = async () => {
12
12
  try {
13
- const res = await axios.get('http://localhost:5006/api/departments/list', { withCredentials: true });
13
+ const res = await axios.get('/api/departments/list', { withCredentials: true });
14
14
  setDepartments(res.data);
15
15
  } catch (err) {
16
16
  console.error(err);
@@ -26,14 +26,14 @@ function Department() {
26
26
  try {
27
27
  if (editingId) {
28
28
  await axios.put(
29
- `http://localhost:5006/api/departments/${editingId}`,
29
+ `/api/departments/${editingId}`,
30
30
  { departmentName },
31
31
  { withCredentials: true }
32
32
  );
33
33
  setMessage('Department updated successfully');
34
34
  } else {
35
35
  await axios.post(
36
- 'http://localhost:5006/api/departments/add',
36
+ '/api/departments/add',
37
37
  { departmentName },
38
38
  { withCredentials: true }
39
39
  );
@@ -56,7 +56,7 @@ function Department() {
56
56
  const handleDelete = async (id) => {
57
57
  if (!window.confirm('Delete this department?')) return;
58
58
  try {
59
- await axios.delete(`http://localhost:5006/api/departments/${id}`, { withCredentials: true });
59
+ await axios.delete(`/api/departments/${id}`, { withCredentials: true });
60
60
  setMessage('Department deleted successfully');
61
61
  if (editingId === id) {
62
62
  setEditingId(null);
@@ -158,3 +158,4 @@ function Department() {
158
158
 
159
159
  export default Department;
160
160
 
161
+
@@ -25,7 +25,7 @@ function Employee() {
25
25
 
26
26
  const getEmployees = async () => {
27
27
  try {
28
- const res = await axios.get('http://localhost:5006/api/employees/list', { withCredentials: true });
28
+ const res = await axios.get('/api/employees/list', { withCredentials: true });
29
29
  setEmployees(res.data);
30
30
  } catch (err) {
31
31
  console.error(err);
@@ -34,7 +34,7 @@ function Employee() {
34
34
 
35
35
  const getDepartments = async () => {
36
36
  try {
37
- const res = await axios.get('http://localhost:5006/api/departments/list', { withCredentials: true });
37
+ const res = await axios.get('/api/departments/list', { withCredentials: true });
38
38
  setDepartments(res.data);
39
39
  } catch (err) {
40
40
  console.error(err);
@@ -43,7 +43,7 @@ function Employee() {
43
43
 
44
44
  const getPositions = async () => {
45
45
  try {
46
- const res = await axios.get('http://localhost:5006/api/positions/list', { withCredentials: true });
46
+ const res = await axios.get('/api/positions/list', { withCredentials: true });
47
47
  setPositions(res.data);
48
48
  } catch (err) {
49
49
  console.error(err);
@@ -91,10 +91,10 @@ function Employee() {
91
91
  };
92
92
 
93
93
  if (editingId) {
94
- await axios.put(`http://localhost:5006/api/employees/${editingId}`, payload, { withCredentials: true });
94
+ await axios.put(`/api/employees/${editingId}`, payload, { withCredentials: true });
95
95
  setMessage('Employee updated successfully');
96
96
  } else {
97
- await axios.post('http://localhost:5006/api/employees/add', payload, { withCredentials: true });
97
+ await axios.post('/api/employees/add', payload, { withCredentials: true });
98
98
  setMessage('Employee added successfully');
99
99
  }
100
100
 
@@ -125,7 +125,7 @@ function Employee() {
125
125
  const handleDelete = async (id) => {
126
126
  if (!window.confirm('Delete this employee?')) return;
127
127
  try {
128
- await axios.delete(`http://localhost:5006/api/employees/${id}`, { withCredentials: true });
128
+ await axios.delete(`/api/employees/${id}`, { withCredentials: true });
129
129
  setMessage('Employee deleted successfully');
130
130
  if (editingId === id) {
131
131
  resetForm();
@@ -374,3 +374,4 @@ function Employee() {
374
374
 
375
375
  export default Employee;
376
376
 
377
+
@@ -18,7 +18,7 @@ function Login() {
18
18
 
19
19
  try {
20
20
  const response = await axios.post(
21
- 'http://localhost:5006/api/auth/login',
21
+ '/api/auth/login',
22
22
  { email, password },
23
23
  { withCredentials: true }
24
24
  );
@@ -82,3 +82,4 @@ function Login() {
82
82
 
83
83
  export default Login;
84
84
 
85
+
@@ -11,7 +11,7 @@ function Position() {
11
11
 
12
12
  const getPositions = async () => {
13
13
  try {
14
- const res = await axios.get('http://localhost:5006/api/positions/list', { withCredentials: true });
14
+ const res = await axios.get('/api/positions/list', { withCredentials: true });
15
15
  setPositions(res.data);
16
16
  } catch (err) {
17
17
  console.error(err);
@@ -27,14 +27,14 @@ function Position() {
27
27
  try {
28
28
  if (editingId) {
29
29
  await axios.put(
30
- `http://localhost:5006/api/positions/${editingId}`,
30
+ `/api/positions/${editingId}`,
31
31
  { posName, requiredQualification },
32
32
  { withCredentials: true }
33
33
  );
34
34
  setMessage('Position updated successfully');
35
35
  } else {
36
36
  await axios.post(
37
- 'http://localhost:5006/api/positions/add',
37
+ '/api/positions/add',
38
38
  { posName, requiredQualification },
39
39
  { withCredentials: true }
40
40
  );
@@ -60,7 +60,7 @@ function Position() {
60
60
  const handleDelete = async (id) => {
61
61
  if (!window.confirm('Delete this position?')) return;
62
62
  try {
63
- await axios.delete(`http://localhost:5006/api/positions/${id}`, { withCredentials: true });
63
+ await axios.delete(`/api/positions/${id}`, { withCredentials: true });
64
64
  setMessage('Position deleted successfully');
65
65
  if (editingId === id) {
66
66
  setEditingId(null);
@@ -177,3 +177,4 @@ function Position() {
177
177
 
178
178
  export default Position;
179
179
 
180
+
@@ -19,7 +19,7 @@ function Register() {
19
19
 
20
20
  try {
21
21
  const response = await axios.post(
22
- 'http://localhost:5006/api/auth/register',
22
+ '/api/auth/register',
23
23
  {
24
24
  name,
25
25
  email,
@@ -103,3 +103,4 @@ function Register() {
103
103
 
104
104
  export default Register;
105
105
 
106
+
@@ -8,7 +8,7 @@ function Reports() {
8
8
 
9
9
  useEffect(() => {
10
10
  axios
11
- .get('http://localhost:5006/api/reports/on-leave-by-department', { withCredentials: true })
11
+ .get('/api/reports/on-leave-by-department', { withCredentials: true })
12
12
  .then((res) => setReport(res.data))
13
13
  .catch((err) => setError(err.response?.data?.message || 'Failed to load report'))
14
14
  .finally(() => setLoading(false));
@@ -90,3 +90,4 @@ function Reports() {
90
90
 
91
91
  export default Reports;
92
92
 
93
+
@@ -3,5 +3,16 @@ import react from '@vitejs/plugin-react'
3
3
  import tailwindcss from '@tailwindcss/vite'
4
4
  // https://vite.dev/config/
5
5
  export default defineConfig({
6
- plugins: [react(),tailwindcss()],
6
+ plugins: [react(), tailwindcss()],
7
+ server: {
8
+ proxy: {
9
+ '/api': {
10
+ target: 'http://localhost:5006',
11
+ changeOrigin: true,
12
+ secure: false,
13
+ cookieDomainRewrite: 'localhost',
14
+ cookiePathRewrite: '/',
15
+ },
16
+ },
17
+ },
7
18
  })