Skip to content

Commit 607bf2d

Browse files
committed
fix: routing in vite app
1 parent 184668c commit 607bf2d

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

Parse-Dashboard/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ module.exports = function (config, options) {
5656
const app = express();
5757
// Serve public files.
5858
app.use(express.static(path.join(__dirname, 'public')));
59-
app.use('/v2', express.static(path.join(__dirname, 'v2')));
6059

6160
// Allow setting via middleware
6261
if (config.trustProxy && app.disabled('trust proxy')) {
@@ -248,9 +247,7 @@ module.exports = function (config, options) {
248247
</html>
249248
`);
250249
} else {
251-
if (options.dev) {
252-
next();
253-
}
250+
next();
254251
}
255252
});
256253
});

Parse-Dashboard/server.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,17 @@ module.exports = options => {
183183
)}`
184184
);
185185
});
186-
if (dev && fs.existsSync(path.join(__dirname, '../v2'))) {
187-
ViteExpress.config({
188-
inlineViteConfig: {
189-
base: `${mountPath}/v2/`,
190-
root: path.join(__dirname, '../v2'),
186+
ViteExpress.config({
187+
inlineViteConfig: {
188+
base: `${mountPath}/v2/`,
189+
root: path.join(__dirname, '../v2'),
190+
build: {
191+
outDir: path.join(__dirname, './v2'),
191192
},
192-
mode: 'development',
193-
});
194-
ViteExpress.bind(app, server);
195-
}
193+
},
194+
mode: dev && fs.existsSync(path.join(__dirname, '../v2')) ? 'development' : 'production',
195+
});
196+
ViteExpress.bind(app, server);
196197
} else {
197198
// Start the server using SSL.
198199
const privateKey = fs.readFileSync(configSSLKey);

v2/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import { CategoryCreate, CategoryEdit, CategoryList, CategoryShow } from './page
2525
import { useRef } from 'react';
2626

2727
function App() {
28-
const first = useRef(location.pathname);
28+
const pathname = location.pathname;
29+
const first = useRef(pathname.substring(0, pathname.indexOf('/v2') + 3));
2930

3031
return (
3132
<BrowserRouter basename={first.current}>

0 commit comments

Comments
 (0)