[SOLVED] REST Error Workaround

When trying to sign up a user with the docs, such as in:

async function signUp() {
    // setLoading(true);
    // setSubmitted(true);

    // if (validateInfo()) {
    //   setLoading(false);
    //   return;
    // }

    // // TODO: error checking
    const user = new Moralis.User();
    user.set("username", username);
    user.set("password", password);
    user.set("email", email);

    try {
      await user.signUp();
      // Hooray! Let them use the app now.
    } catch (error) {
      // Show the error message somewhere and let the user try again.
      alert("Error: " + error.code + " " + error.message);

    let { from, ...rest } = location.state || { from: { pathname: "/" } };
    props.history.push({ pathname: from.pathname, search: from.search, state: rest });

We get a rest error, as it tries to send it to our backend

Error: 107 Received an error with invalid JSON from Parse: <!DOCTYPE html>
<html lang="en">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>Page not found at /users</title>
  <meta name="robots" content="NONE,NOARCHIVE">
  <style type="text/css">
    html * { padding:0; margin:0; }
    body * { padding:10px 20px; }
    body * * { padding:0; }
    body { font:small sans-serif; background:#eee; color:#000; }
    body>div { border-bottom:1px solid #ddd; }
    h1 { font-weight:normal; margin-bottom:.4em; }
    h1 span { font-size:60%; color:#666; font-weight:normal; }
    table { border:none; border-collapse: collapse; width:100%; }
    td, th { vertical-align:top; padding:2px 3px; }
    th { width:12em; text-align:right; color:#666; padding-right:.5em; }
    #info { background:#f6f6f6; }
    #info ol { margin: 0.5em 4em; }
    #info ol li { font-family: monospace; }
    #summary { background: #ffc; }
    #explanation { background:#eee; border-bottom: 0px none; }
    pre.exception_value { font-family: sans-serif; color: #575757; font-size: 1.5em; margin: 10px 0 10px 0; }
  <div id="summary">
    <h1>Page not found <span>(404)</span></h1>
    <table class="meta">
        <th>Request Method:</th>
        <th>Request URL:</th>
  <div id="info">
      Using the URLconf defined in <code>backend.urls</code>,
      Django tried these URL patterns, in this order:
          The current path, <code>users</code>,
        didn’t match any of these.

  <div id="explanation">
      You’re seeing this error because you have <code>DEBUG = True</code> in
      your Django settings file. Change that to <code>False</code>, and Django
      will display a standard 404 page.

we have set axios.defaults.baseURL value to our backend url

It seems to me that Moralis is using that baseURL for their code. Is there some kind of workaround?

1 Like

Did you set SERVER_URL for Moralis server?

Looks like we forgot that. Thanks very much! :slight_smile: