Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finwise-miniapp-fe
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ThinhNC
finwise-miniapp-fe
Commits
8068b030
Commit
8068b030
authored
Oct 15, 2026
by
ThinhNC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(router): use transform plugin on original ZMPRouter to fix local zmp start and vercel
parent
2ec6f4fd
Pipeline
#53710
canceled with stage
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
layout.tsx
src/components/layout.tsx
+1
-1
vite.config.mts
vite.config.mts
+28
-9
No files found.
src/components/layout.tsx
View file @
8068b030
...
...
@@ -4,9 +4,9 @@ import {
App
,
Route
,
SnackbarProvider
,
ZMPRouter
,
useNavigate
,
}
from
"zmp-ui"
;
import
{
ZMPRouter
}
from
"@/components/router/ZMPRouter"
;
import
{
QueryClientProvider
}
from
"@tanstack/react-query"
;
import
{
queryClient
}
from
"@/lib/query-client"
;
import
{
useAuthStore
,
GUEST_STORAGE_KEY
}
from
"@/stores/auth-store"
;
...
...
vite.config.mts
View file @
8068b030
import { defineConfig } from "vite";
import { defineConfig
, Plugin
} from "vite";
import zaloMiniApp from "zmp-vite-plugin";
import react from "@vitejs/plugin-react";
import path from "path";
/**
* Patch ZMPRouter to only force `/zapps/<APP_ID>` basepath when inside Zalo (pathname starts with /zapps/).
* When running on Vercel or standalone web, basepath remains "" so standard routes (/, /login) work properly.
* In local `zmp start`, appEnv === "DEVELOPMENT" handles the basepath natively with zero context mismatch.
*/
function patchZmpRouterPlugin(): Plugin {
return {
name: "patch-zmp-router-for-web",
transform(code, id) {
if (id.includes("ZMPRouter")) {
return {
code: code.replace(
'process.env.NODE_ENV === "production"',
'(typeof window !== "undefined" && window.location.pathname.startsWith("/zapps/") && process.env.NODE_ENV === "production")'
),
map: null,
};
}
return null;
},
};
}
// https://vitejs.dev/config/
export default () => {
return defineConfig({
base: "",
plugins: [zaloMiniApp(), react()],
plugins: [
patchZmpRouterPlugin(),
zaloMiniApp(), react()],
build: {
assetsInlineLimit: 0,
},
resolve: {
alias: [
{ find: "@", replacement: path.resolve(__dirname, "./src") },
{
find: /.*\/components\/router\/ZMPRouter(\.js)?$/,
replacement: path.resolve(__dirname, "./src/components/router/ZMPRouter.tsx"),
},
],
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment