useful-bronze
useful-bronze17mo ago

Error Can't resolve 'fs'

Hello everyone, I'm facing an error integrating Casbin accessControlProvider here is the code for accessControlProvider I followed from the documentation accessControlProvider={{ can: async ({ resource, action }) => { const enforcer = await newEnforcer(model, adapter); const can = await enforcer.enforce('admin', resource, action); return { can }; }, }} And its showing Can't resolve 'fs'
No description
5 Replies
kapa.ai
kapa.ai17mo ago
Hey @franzdev! I'm the kapa.ai support bot. I've searched through the docs to try to answer your question. :wave:
kapa.ai
kapa.ai17mo ago
---------------------- To resolve the "Can't resolve 'fs'" error when integrating Casbin with refine, you need to configure polyfills for casbin to work in a browser environment. You can use react-app-rewired to override some of the configurations of your app. Follow these steps: 1. Add react-app-rewired to your project:
yarn add react-app-rewired
yarn add react-app-rewired
2. Update the scripts in your package.json:
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"eject": "react-scripts eject",
"refine": "refine"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"eject": "react-scripts eject",
"refine": "refine"
},
3. Add the following packages:
yarn add assert buffer crypto-browserify stream-browserify
yarn add -D https-browserify os-browserify path stream-http
yarn add assert buffer crypto-browserify stream-browserify
yarn add -D https-browserify os-browserify path stream-http
4. Include the config-overrides.js file in the root of your app folder. You can find the file here (https://github.com/anewman15/refine/blob/pixels-admin/examples/pixels-admin/config-overrides.js). After completing these steps, the error should be resolved. For more information, refer to the Browser Fallbacks for Casbin section (https://refine.dev/blog/refine-pixels-6/#browser-fallbacks-for-casbin) in the refine blog. ----------------------
Implementing Role Based Access Control | refine
We'll implement Role Based Access Control (RBAC)
kapa.ai
kapa.ai17mo ago
<@619660544319684609> kapa.ai is still learning and improving, please let us how it did by reacting below
useful-bronze
useful-bronze17mo ago
Now I'm getting this error
No description
useful-bronze
useful-bronze17mo ago
access-control-casbin - CodeSandbox
access-control-casbin using @refinedev/antd, @refinedev/cli, @refinedev/core, @refinedev/react-router-v6, @refinedev/simple-rest, @types/node, @types/react, @types/react-dom, @uiw/react-md-editor