cli icon indicating copy to clipboard operation
cli copied to clipboard

Forms not sending POST, returning 404

Open LandGod opened this issue 4 years ago • 2 comments

Describe the bug When submitting a form that is wired up as a Netlify form (ie: has data-netlify="true"), I am redirected to the form submit success page, but just get an otherwise blank page that says "Function not found..." and see a 404 in the console for the POST request.

To Reproduce Steps to reproduce the behavior: I am unfortunately unable to provide a link to our Github repo as it is private, however we have the forms working as intended on our live site at jaquishbiomedical.com (there is a newsletter signup in the footer). That form is tested and working on the live site and has been working for quite some time.

Here is the relevant HTML if it helps, and I am happy to provide any further information that I can if it would be of use. This is copied straight from Chrome devtools on my machine running from netlify dev.

HTML
          <form name="newsletter" class="flex justify-center mt-2 event-trigger lg:flex-wrap" method="POST" action="/form-success/" enctype="application/x-www-form-urlencoded" data-netlify="true" data-event-name="newsletter" data-param-category="engagement" data-param-label="newsletter" netlify-honeypot="bot-field" _lpchecked="1">
            <label class="honey">
              Don't fill this out if you're human:
              <input name="bot-field" tabindex="-1"></label>
            <label for="newsletter-email" class="sr-only">
              Email
            </label>
            <input id="newsletter-email" required="" type="email" name="email" class="h-10 pl-2 mb-2 border border-gray-200 rounded shadow-inner md:mb-0" placeholder="Email address" data-test="newsletter-signup-input">
            <input type="hidden" name="title" value="Contact Us">
            <input type="hidden" name="relpermalink" value="/contact/">
            <button type="submit" class="h-10 md:m-1 btn btn-primary btn-sm md:mt-0 md:mb-0 lg:mt-2" data-test="newsletter-signup-send-button">
              Subscribe
            </button>
          </form>

Configuration

Netlify.toml
# Default build command.
[build]
publish = "public"
functions = "netlify-lambda"
command = "hugo --gc --minify --baseURL $URL --environment production"
HUGO_VERSION = "0.78.2"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"


##############################################################################
# Master branch context: all deploys from the Master branch set in your site's
# deploy contexts will inherit these settings.
##############################################################################

[context.master]
command = "hugo --gc --minify --enableGitInfo --baseURL $URL --environment production"

[context.master.environment]
HUGO_ENV = "production"
HUGO_VERSION = "0.78.2"
HUGO_ENABLEGITINFO = "true"


##############################################################################
# Staging branch context: all deploys from the staging branch set in your site's
# deploy contexts will inherit these settings.
##############################################################################

[context.staging]
command = "hugo --gc --minify --enableGitInfo --baseURL $URL --environment development"

[context.staging.environment]
HUGO_ENV = "development"
HUGO_VERSION = "0.78.2"
HUGO_ENABLEGITINFO = "true"

##############################################################################
# Deploy Preview context: all deploys generated from a pull/merge request will
# inherit these settings.
##############################################################################

[context.deploy-preview]
command = "hugo --gc --buildFuture --baseURL $DEPLOY_PRIME_URL --environment development"

[context.deploy-preview.environment]
HUGO_ENV = "development"
HUGO_VERSION = "0.78.2"
HUGO_ENABLEGITINFO = "true"

##############################################################################
# Devstore Deploy Context: 
# 
##############################################################################

[context.task1314c]
command = "hugo --gc --minify --enableGitInfo --baseURL $URL --environment devstore --config config.toml,devstoreconfig.toml"

[context.task1314c.environment]
HUGO_ENV = "devstore"
HUGO_VERSION = "0.78.2"
HUGO_ENABLEGITINFO = "true"


##############################################################################
# Branch Deploy context: all deploys that are not from a pull/merge request or
# from the Production branch will inherit these settings.
##############################################################################

[context.branch-deploy]
command = "hugo --gc --baseURL $DEPLOY_PRIME_URL --environment development"

[context.branch-deploy.environment]
HUGO_ENV = "development"
HUGO_VERSION = "0.78.2"
HUGO_ENABLEGITINFO = "true"


##############################################################################
# devsite.jaquishbiomedical.com just a site to always have the devstore products running
##############################################################################

[context.devstore]
command = "hugo --gc --minify --enableGitInfo --baseURL $URL --config config.toml,devstoreconfig.toml --environment devstore"

[context.devstore.environment]
HUGO_ENV = "development"
HUGO_VERSION = "0.77.0"
HUGO_ENABLEGITINFO = "true"

##############################################################################
# Develop site context: must manually set branch
##############################################################################

[context.task1708-new-hide-free-shipping-for-non-us]
command = "hugo --gc --minify --enableGitInfo --baseURL $URL --environment development"

[context.task1708-new-hide-free-shipping-for-non-us.environment]
HUGO_ENV = "development"
HUGO_VERSION = "0.78.2"
HUGO_ENABLEGITINFO = "true"

##############################################################################
# Plugins
##############################################################################
#[[plugins]]
#package = "netlify-plugin-cypress"
#    [plugins.inputs]
#    record = true

##############################################################################
# Headers
# For info about Netlify/TOML header formatting see: https://docs.netlify.com/routing/headers/#syntax-for-the-headers-file
##############################################################################
[[headers]]
  for = "/*"
  [headers.values]
    Access-Control-Allow-Origin = "*"
    Strict-Transport-Security = '''
    max-age=63072000,
    includeSubDomains, 
    preload'''
  
# Proxy Caching
# The default Netlify cache-control header, are `max-age=0, must-revalidate, public` which means all content should be cached but also re-validated.
# `s-max-age` Takes precedence over `max-age` or the `Expires` header, but it only applies to shared caches (e.g., proxies) and is ignored by a private cache. This means we’re using custom headers on Netlify to tell Cloudflare (our CDN) how long to cache assets. We’ll then control how long browsers cache using CDN settings.
# 604800 seconds translates to 7 days, so during normal operation Cloudflare will cache images, CSS and JavaScript files for 7 days.
# Even if Cloudflare has cached our .css or .js we are using adding a hash to the filenames which causes any chance to be cache busting. Hugo has a cache-busting hash baked in called fingerprinting.  Old versions and new versions will be fetched and cached separately due to this new filename with a hash. This makes it safe to aggressively cache across the CDN and in browsers.
# For more info: https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#defining_optimal_cache-control_policy 

# ******** Non-hashed static assets ********
# These we're ok caching for 7 days on a local machine and 7 days on Edge. (see above)
[[headers]]
  for = "/img-gen/*"
  [headers.values]
    cache-control = '''
    public, 
    s-max-age=604800, 
    max-age=604800'''

[[headers]]
  for = "/images*"
  [headers.values]
    cache-control = '''
    public, 
    s-max-age=604800, 
    max-age=604800'''

[[headers]]
  for = "/fonts/*"
  [headers.values]
    cache-control = '''
    public, 
    s-max-age=604800, 
    max-age=604800'''

[[headers]]
  for = "/favicon/*"
  [headers.values]
    cache-control = '''
    public, 
    s-max-age=604800, 
    max-age=604800'''

# ******** Hashed assets ********
# These we're ok to cache for 1 year on a local machine and 1 year on Edge (see above)

[[headers]]
  for = "/*.css"
  [headers.values]
    cache-control = '''
    public, 
    s-max-age=31536000, 
    max-age=31536000'''
  
[[headers]]
  for = "/*.js"
  [headers.values]
    cache-Control = '''
    public, 
    s-max-age=31536000, 
    max-age=31536000'''

Config output:

System:
    OS: Windows 10 10.0.18363
    CPU: (8) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
    Memory: 5.74 GB / 15.96 GB
  Binaries:
    Node: 12.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\Documents\Programming\JanquishBioMed\jbm-marketing-site\node_modules\.bin\yarn.CMD
    npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    netlify-cli: ^2.69.0 => 2.69.0 

Expected behavior I don't need the form to "work" per-say, but I would like to get a status 200 and a redirect to my success page as I would see when submitting this form on the live site.

CLI Output

I've tried submitting multiple times with the same result and the same console output:

Request from ::1: POST /form-success/
Response with status 404 in 2 ms.

Update

  • Issue persists on latest version of Netlify CLI: netlify-cli/3.10.7 win32-x64 node-v14.15.1

LandGod avatar Nov 30 '20 22:11 LandGod

I'm having the same issue

oristian avatar Jan 04 '21 20:01 oristian

Same issue here. I have tried all the troubleshooting steps and searched through several forums.

bradeneast avatar May 02 '22 03:05 bradeneast

Hey @oristian & @bradeneast, is there any public repository through which I can reproduce the issue?

tinfoil-knight avatar Sep 28 '22 16:09 tinfoil-knight

Closing as stale. Please re-open if needed

sarahetter avatar Sep 14 '23 16:09 sarahetter