[netlify-plugin-gatsby] Does not deploy Lambda function when Netlify redirects are defined

First I’m not 100% sure if this is a bug with Netlify (the Netlify CLI itself) or if it’s related to this plugin. So hopefully someone with more insights can help here: when there is already a _redirects file defined in the static/ directory this plugin indeed does create correctly the following entry at the end of the file

## Created with gatsby-plugin-netlify
/foo/*  /  301
# @netlify/plugin-gatsby redirects start
/api/* /.netlify/functions/gatsby 200
# @netlify/plugin-gatsby redirects end

but the Lambda function itself is not deployed. From the Netlify CLI I’m getting

(Netlify Build completed in 3m 26.6s)
Deploy path:        /Users/me/Workspace/some-site/public
Configuration path: /Users/me/Workspace/some-site/netlify.toml
Deploying to draft URL...
✔ Finished hashing 4242 files
✔ CDN requesting 42 files
✔ Finished uploading 42 assets
✔ Deploy is live!

When I completely remove the static/_redirects file the Netlify CLI output is

(Netlify Build completed in 3m 31.2s)
Deploy path:        /Users/me/Workspace/some-site/public
Functions path:     /Users/me/Workspace/some-site/netlify/functions
Configuration path: /Users/me/Workspace/some-site/netlify.toml
Deploying to draft URL...
✔ Deploying functions from cache (use --skip-functions-cache to override)
✔ Finished hashing 4242 files and 1 functions
✔ CDN requesting 42 files and 0 functions
✔ Finished uploading 42 assets
✔ Deploy is live!

On the third line there is the indicator that the function is found and deployed. I’m using additionally gatsby-plugin-netlify in combination with @netlify/plugin-gatsby.

Steps to reproduce

  1. create a new Gatsby project
  2. create a Lambda function in src/api/
  3. create a static/_redirects file with one or more redirects. For example /foo/* / 301
  4. build the project with npx netlify deploy --build

The same happens when a _redirects file is not present but created programatically in gatsby-node.js with

exports.createPages = async ({ actions }) => {
  const { createRedirect } = actions;

    fromPath: '/foo/*',
    toPath: '/',
    statusCode: 301,

I already created a GitHub issue for that but unfortunately did not receive a feedback yet.

Hey there, @HotOrange :wave:

Apologies for the delay! Can you try updating to the latest version of the plugin? The release information is here: Releases · netlify/netlify-plugin-gatsby · GitHub

Hi :wave:

thank you for the response. Unfortunately the latest version 4.1.0 of gatsby-plugin-netlify is not compatible with Gatsby V3. Only with Gatsby V4 which I cannot use yet because of some plugins that I need that needs to be updated. Are there any plans to fix that also in the 3.x branch of your plugin?

Hey there, @HotOrange :wave:

Thanks for following up and clarifying! I can ask the plugin author and report back!

1 Like

Hey there, @HotOrange :wave:

Thanks for your patience here! The plugin author will continue following up on the issue you linked above. Thanks!

1 Like