Nuxt.js: bug(csr): error page layout not correctly applied

Created on 9 Jan 2018  路  26Comments  路  Source: nuxt/nuxt.js

//layouts\error.vue
{
layout: 'empty'
}

route to a 404 page.the error page layout is right

error1

but a page component has code error.

error2

when route to this page.

the error page layout is layouts\default.vue not layouts\error.vue


at [email protected] not this problem.

This question is available on Nuxt.js community (#c2205)
bug-confirmed bug-report pending

Most helpful comment

Get the same error.

If refreshing the URL with 404, the correct layout is applied.

If visiting the URL via a broken link within the same state, then the layout remains from the previous page (e.g. with nav and all).

All 26 comments

I'm having this same issue since upgrading to 1.0

--

As a temporary fix, I've created an empty layout...

// in layouts/error.vue
layout: 'empty',

and in layouts/empty.vue

<template><nuxt /></template>

<script>
export default { name: 'EmptyLayout' };
</script>

I am having the same issue.

I have two layouts in my layout directory, default.vue and error.vue.
The default layout is named default-layout and the error layout is named nuxt-error

When an error occurs, nuxt is rendering the error layout inside of the default layout as seen here:

Screenshot

Is an undocumented change, the error layout is no longer a layout and it works like a page

@cesasol Oh really? Could you point me to the PR that was merged of this change please?

If you are right, it would have been nice to have that in the release notes, as I would consider it a breaking change!

I don't know, I upgraded, noted this and updated my code accordingly, yes it should be on the release notes but maybe not as a breaking change.

@pi0

@cesasol I did the same, and it all works fine, but it's not the best way to experience a change. I've had a quick look through merged PRs and none stood out to me that were linked to this, which still makes me doubt whether this is an intentional change or a regression.

Also, I would myself consider this breaking, as it broke my error page.

If someone can give me evidence that this is an intentional change, I'll be more than happy to make a PR updating the docs with this.

This seems to be resolved now. Closing. Reopen if still happens.

@husayt it sitll happens at nuxt 1.4.0

Still have this issue

Get the same error.

If refreshing the URL with 404, the correct layout is applied.

If visiting the URL via a broken link within the same state, then the layout remains from the previous page (e.g. with nav and all).

I think we need a function that don't use any layout.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as 馃晲Pending will not be automatically marked as stale.

If refreshing the URL with 404, the correct layout is applied.
If visiting the URL via a broken link within the same state, then the layout remains from the previous page (e.g. with nav and all).

I'm using nuxt-edge 2.4.0 and this still happens.
@moltar have you found any solution?

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as 馃晲Pending will not be automatically marked as stale.

#5654 :bug:

@Atinux @pi0
any news on this ?

any news on this ?

Encountered this issue in Nuxt 2.8.1

Any update?

Same on 2.9.2
The page 200.html is not generate properly

Same on 2.9.2

@clarkdo I've reassigned you here and closed #5654 as duplicate.

Still having the problem.. any update guys?

Still have this problem. SPA mode. When calling $nuxt.error, the error.vue page is rendered inside the default.vue layout, ignoring the empty layout specified in the error.vue page itself.

pages/test.vue

export default {
    name: 'test',
    async fetch() {
        try {
            //get some bad URL
        } catch(e) {
            this.$nuxt.error('This will render the error as a route within default.vue, ignoring the error page layout')
        }
    }
}

layouts/error.vue

export default {
        layout: 'empty', //ignored
        props: {
            error: {
                type: Object,
                default: null
            }
        }
    }

layouts/empty.vue

<template>
    <nuxt/>
</template>

Still have this problem. SPA mode. When calling $nuxt.error, the error.vue page is rendered inside the default.vue layout, ignoring the empty layout specified in the error.vue page itself.

pages/test.vue

export default {
  name: 'test',
  async fetch() {
      try {
          //get some bad URL
      } catch(e) {
          this.$nuxt.error('This will render the error as a route within default.vue, ignoring the error page layout')
      }
  }
}

layouts/error.vue

export default {
      layout: 'empty', //ignored
      props: {
          error: {
              type: Object,
              default: null
          }
      }
  }

layouts/empty.vue

<template>
  <nuxt/>
</template>

having exactly the same problem. if error is thrown the default layout applies and layout: 'empty' is ignored

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

danieloprado picture danieloprado  路  3Comments

surmon-china picture surmon-china  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments