Skip to content

[Bug]: Next Redirects don't get persisted if netlify build and netlify deploy are run seperately #1995

Closed as not planned
@DavidWells

Description

@DavidWells

Summary

When trying to deploy a site manually via Netlify CLI the redirects aren't persisted.

Here's what didn't work:

netlify build && netlify deploy --prod

Here's what ultimately did work:

netlify deploy --build --prod

When you run netlify build it says its adding redirects like so:

Netlify configuration property "redirects" value changed to [
  { from: '/_next/static/*', to: '/static/:splat', status: 200 },
  {
    from: '/_next/image*',
    query: { url: ':url', w: ':width', q: ':quality' },
    to: '/_ipx/w_:width,q_:quality/:url',
    status: 301
  },
  { from: '/_ipx/*', to: '/.netlify/builders/_ipx', status: 200 },
  { from: '/cache/*', to: '/404.html', status: 404, force: true },
  { from: '/server/*', to: '/404.html', status: 404, force: true },
  { from: '/serverless/*', to: '/404.html', status: 404, force: true },
  { from: '/trace', to: '/404.html', status: 404, force: true },
  { from: '/traces', to: '/404.html', status: 404, force: true },
  {
    from: '/routes-manifest.json',
    to: '/404.html',
    status: 404,
    force: true
  },
  {
    from: '/build-manifest.json',
    to: '/404.html',
    status: 404,
    force: true
  },
  {
    from: '/prerender-manifest.json',
    to: '/404.html',
    status: 404,
    force: true
  },
  {
    from: '/react-loadable-manifest.json',
    to: '/404.html',
    status: 404,
    force: true
  },
  { from: '/BUILD_ID', to: '/404.html', status: 404, force: true },
  {
    from: '/api/*',
    to: '/.netlify/functions/___netlify-handler',
    status: 200
  },
  {
    from: '/_redirects',
    to: '/_redirects',
    conditions: { Cookie: [Array] },
    status: 200
  },
  {
    from: '/*',
    to: '/.netlify/functions/___netlify-handler',
    status: 200,
    conditions: { Cookie: [Array] },
    force: true
  },
  {
    from: '/_next/data/1QYE_ME3iWBSXQ3TmbKeN/index.json',
    to: '/.netlify/functions/___netlify-handler',
    status: 200,
    force: false
  },
  {
    from: '/',
    to: '/.netlify/functions/___netlify-handler',
    status: 200,
    force: false
  },
  {
    from: '/*',
    to: '/.netlify/functions/___netlify-handler',
    status: 200
  }
].

But these aren't actually processed or saved anywhere in the build and the subsequent netlify deploy is "redirectless"

Might want to add this to the docs somewhere or make the output of the CLI more clear on what users of the plugin need to do.

This guys post saved me in the end https://paulonteri.com/thoughts/how-to/deploy-nextjs-to-netlify-manually

Steps to reproduce

Listed above

A link to a reproduction repository

No response

Next Runtime version

latest

Is your issue related to the app directory (beta)?

  • Yes, I am using the app directory

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?

None

Your netlify.toml file

`netlify.toml`
# Paste content of your `netlify.toml` file here

Your public/_redirects file

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

Your next.config.js file

`next.config.js`
# Paste content of your `next.config.js` file here. Check there is no private info in there.

Builds logs (or link to your logs)

Build logs
# Paste logs here

Function logs

Function logs
# Paste logs here

.next JSON files

generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions