@marvalt/madapter 2.3.4 → 2.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -77,7 +77,8 @@ class MauticClient {
77
77
  * Submit a form to Mautic
78
78
  */
79
79
  async submitForm(formId, submission) {
80
- const endpoint = `/form/submit?formId=${formId}`;
80
+ // Endpoint should be just the path, without query string (formId is in the body)
81
+ const endpoint = `/form/submit`;
81
82
  // Encode as application/x-www-form-urlencoded to match Mautic expectations
82
83
  const formParams = new URLSearchParams();
83
84
  // Add fields
@@ -1826,6 +1827,20 @@ const getMauticClient = () => {
1826
1827
  if (!defaultClient) {
1827
1828
  // Lazy initialize the client from environment if not set by provider/service
1828
1829
  const config = createMauticConfig();
1830
+ // In development with VITE_LOCAL_DEVELOPMENT=true, use Wrangler server for proxy
1831
+ try {
1832
+ // @ts-ignore - import.meta is a Vite-specific global
1833
+ const isDev = typeof import.meta !== 'undefined' && import.meta.env?.DEV;
1834
+ // @ts-ignore
1835
+ const isLocalDev = typeof import.meta !== 'undefined' && import.meta.env?.VITE_LOCAL_DEVELOPMENT === 'true';
1836
+ const useWranglerProxy = isDev && isLocalDev;
1837
+ if (useWranglerProxy) {
1838
+ config.proxyEndpoint = 'http://127.0.0.1:8788/api/mautic-submit';
1839
+ }
1840
+ }
1841
+ catch (e) {
1842
+ // import.meta not available, use default config
1843
+ }
1829
1844
  defaultClient = new MauticClient(config);
1830
1845
  }
1831
1846
  return defaultClient;