Closed bryanreyeslanexcorp closed 11 months ago
Hi @bryanreyeslanexcorp
Can you share what the Internal Server Error is? You'll need to provide the error message obtained in the bench console. This does not seem to be an issue with the library. Can you also share the parameters you have passed to FrappeProvider?
Thanks.
Hello @nikkothari22 Thanks for prompt response. I think I just resolved this issue by adding a value on url. I just followed on what you did in your live session with BuildWithHussain. It works for the first time but for some reason, it wasn't. So I tried to add the a value on url and now it works.
<FrappeProvider socketPort={import.meta.env.VITE_PORT ?? ''} url='http://localhost:8001'>
<BrowserRouter basename={import.meta.env.VITE_BASE_PATH}>
<Routes>
<Route path='/' element={<RandomPeople />} />
</Routes>
</BrowserRouter>
</FrappeProvider>
Just a question, Is it possible just to have a react alone and not under on the bench-app structure?
Hi, I faced the same issue today but with different mistakes in the program. Thought to share since, it can help others
here is my main.tsx
file. applied the above solution unfortunately, It didn't work for me
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<FrappeProvider socketPort={import.meta.env.VITE_SOCKET_PORT ?? ""}>
<BrowserRouter basename={import.meta.env.VITE_BASE_PATH}>
<Routes>
<Route path="/" element={<App />} />
</Routes>
</BrowserRouter>
</FrappeProvider>
</React.StrictMode>
);
Assuming common_site_config.json
is having "allow_cors": "*"
and "ignore_csrf": 1
as mentioned above.The following checks will help -
bench use <site-name-without-port-number>
const common_site_config = require('../../../sites/common_site_config.json');
const { webserver_port } = common_site_config;
export default {
'^/(app|api|assets|files|private)': {
target: http://localhost:${webserver_port}
,
ws: true,
router: function (req) {
const site_name = req.headers.host.split(':')[0];
return http://${site_name}:${webserver_port}
;
}
},
};
Finally, running `bench use <site-name-without-port-number>` did the trick
Just a question, Is it possible just to have a react alone and not under on the bench-app structure?
Yeah, it's possible to do that. You would need to pass the URL for it to work.
If your domains (React app and frappe backend) are going to be different, then cookie based authentication won't work since SameSite is set to Lax/Strict in Frappe. In that case, you would need to use Token based auth (which the SDK supports).
At first it works fine, however after a few testing it produces Internal Server Error. I tried to create from scratch however it is no longer working.
Sample Code usage:
common_site_config.json