-
-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow integrating toolpad applications in a custom server #2747
Conversation
Putting up for rereview. I turned this PR into exporting the toolpad handler as it turned out there were more things that needed to be done than was initially proposed |
This comment was marked as resolved.
This comment was marked as resolved.
dev: process.env.NODE_ENV === 'development', | ||
base: appBase, | ||
}); | ||
app.use('/my-app', handler.handler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in the example /my-app
is the path that the whole Toolpad runs under including the editor in dev mode, and /my-app
is the base path where the production app runs?
If so, should they be different to be more obvious?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
including the editor in dev mode
Not the editor, only the application. For editing I'm envisioning the following:
- you start your custom server with the Toolpad handler in dev mode.
- you run
yarn toolpad --connect http://localhost:3000/my-app
- then follow the link that's printed to open the editor where the canvas is actually pointing to your custom server
Only the end user application runs in your server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that sounds cool!
Are there cases where the first argument for app.use
and appBase
would not be the same, though? Or could they share the same variable?
Anyway that's not important at all so I'm approving already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's an example. for demonstration purposes is it a bit clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed a couple of things maybe worth mentioning, everything else looks good!
How are you running it? The following should work:
|
Export a
unstable_createHandler
which can be used to integrated in a custom server. See example.Can be imported as ESM, should also work under commonjs. In any case it can always dynamically be imported as ESM under commonjs.
Changes include:
unstable_createHandler
projectRoot
. (dead code)Follow up work includes: