Skip to content
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

set projectURl and baseUrl on pre-request #56

Merged
merged 1 commit into from
May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/helpers/FormioLoader/FormioLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const requestPluginHandler = (requestArgs, opts) => {
requestArgs.opts.base = requestArgs.formio.options.base;
requestArgs.opts.project = requestArgs.formio.options.project;
requestArgs.opts.namespace = requestArgs.formio.options.namespace;
Formio.setProjectUrl(requestArgs.formio.options.project);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm global, that is strange. how many of these 'gotchas' have we come accross.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actual did fix in few places, as in formio.js, there are few ocassions using Formio.getProjectUrl to contruct URL for internal request, such as PDF, nested Form, Select (using data resource). (not every component using this method to construct URL tho, eg. ReCaptcha)

by adding Formio.setProjectUrl in pre-request hook, hence update the global Formio just before the request, luckily we still can support multiple forms with this patch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the discovery, could you raise and issue on the formio js upstream project with examples where they missed local variable instead of global with the proviso to doing multi form on one page with different 'stages/projects'

Formio.setBaseUrl(requestArgs.formio.options.base);
}
}

Expand Down