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

[Bug]: Statuscode from getPageData is not applied #749

Open
2 tasks done
manuelJung opened this issue Mar 6, 2024 · 1 comment
Open
2 tasks done

[Bug]: Statuscode from getPageData is not applied #749

manuelJung opened this issue Mar 6, 2024 · 1 comment

Comments

@manuelJung
Copy link

Summary

export async function getServerData() {
  return {
    status: 404,
    props: {},
  }
}

when my getServerData fn on a ssr route returns a 404 status (or any other statuscode) netlify will always send a 200 statuscode since this is hardcoded (which can be seen here). when data.serverDataStatus yields a 404 or 500 we should return the getErrorResponse fn instead

Steps to reproduce

  • create a gatsby project with an ssr route and add
export async function getServerData() {
  return {
    status: 404,
    props: {},
  }
}
  • deploy it to netlify (or serve with netlify locally)
  • call the ssr-route in the browser an see the statuscode send from netlify (it will be a 200)

! serving with gatsby (gatsby serve) wont work since here it works correctly)

A link to a reproduction repository

No response

Plugin version

3.8.0

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

Mac OS

Your netlify.toml file

`netlify.toml`
[build]
ignore = "exit 0"
functions = "./netlify/functions"
publish = "public/"

[build.environment]
NODE_OPTIONS = "--max_old_space_size=8192"

[[plugins]]
package = "@netlify/plugin-gatsby"

[[headers]]
for = "*"

[headers.values]
cache-control = """

                    max-age=0,
                    no-cache,
                    no-store,
                    must-revalidate"""

[[headers]]
for = "*.json"

[headers.values]
cache-control = """

                    private,
                    no-cache,
                    no-store"""

[[headers]]
for = "*.js"

[headers.values]
cache-control = """

                    public,
                    max-age=172800,
                    must-revalidate"""

Configuration

`gatsby-config.js` and options
# Paste content of your `gatsby-config.js` file, and/or command line options here. Check there is no private info in there.

Environment

Environment
System:
    OS: macOS 13.3
    CPU: (10) arm64 Apple M1 Max
    Memory: 2.88 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.11.0 - ~/.nvm/versions/node/v18.11.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.11.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.11.0/bin/npm
  Browsers:
    Brave Browser: 114.1.52.130
    Chrome: 122.0.6261.94
    Safari: 16.4

Gatsby info

gatsby info
System:
    OS: macOS 13.3
    CPU: (10) arm64 Apple M1 Max
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.11.0 - ~/.nvm/versions/node/v18.11.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.11.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.11.0/bin/npm
  Languages:
    Python: 2.7.18 - /Users/.../.pyenv/shims/python
  Browsers:
    Chrome: 122.0.6261.94
    Firefox: 120.0.1
    Safari: 16.4
  npmPackages:
    gatsby: ^5.10.0 => 5.11.0
    gatsby-plugin-eslint: ^4.0.4 => 4.0.4
    gatsby-plugin-google-tagmanager: ^5.10.0 => 5.11.0
    gatsby-plugin-graphql-codegen: ^3.1.1 => 3.1.1
    gatsby-plugin-manifest: ^5.10.0 => 5.11.0
    gatsby-plugin-netlify: ^5.1.0 => 5.1.0
    gatsby-plugin-react-helmet: ^6.10.0 => 6.11.0
    gatsby-plugin-react-svg: ^3.3.0 => 3.3.0
    gatsby-plugin-resolve-src: ^2.1.0 => 2.1.0
    gatsby-plugin-sitemap: ^6.10.0 => 6.11.0
    gatsby-plugin-typescript: ^5.10.0 => 5.11.0
  npmGlobalPackages:
    gatsby-cli: 5.10.0

Your _redirects file

`_redirects`
# Paste content of your `_redirects` file here

Builds logs (or link to your logs)

Build logs
# Paste logs here

Function logs

Function logs
# Paste logs here
@malteeckhoff
Copy link

malteeckhoff commented Mar 19, 2024

I am afraid this issue is causing me some trouble as well. A fix would be highly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants