nuxt-community / netlify-files-module

Nuxt 2 module to create new _headers, _redirects and netlify.toml files for Netlify or to use existing ones
MIT License
50 stars 5 forks source link

async netlifyToml function returns empty netlify.toml file #28

Open Aztriltus opened 3 years ago

Aztriltus commented 3 years ago

When using netlifyToml as a normal function in nuxt.config.js as so:

export default {
  // ...
  netlifyFiles: {
    copyExistingFiles: false,
    netlifyToml() {
      return {
        redirects: [{ from: '/test', to: '/test-1', status: 301}]
      }
    }
  }
}

The module returns a correct netlify.toml file after yarn generate

[[redirects]]
from = "test"
to = "test-1"
status = 301

But when using an async function as so:

// Just an example
function redirects() {
  return new Promise(resolve => {
    resolve({
      redirects: [
        {
          from: "test",
          to: "test-1",
          status: 301
        }
      ]
    });
  });
}

export default {
  // ...
  netlifyFiles: {
    copyExistingFiles: false,
    async netlifyToml() {
      return await redirects();
    }
  }
}

A netlify.toml will be generated in /dist, but the content is blank.

Any idea?

bootsmann1995 commented 2 years ago

@Aztriltus did you manage to fix this?

Aztriltus commented 2 years ago

Hey @bootsmann1995 I didn't manage to. I've used another way of redirecting now

wiven commented 2 years ago

I'm running into the same issue. When using an async function the object is empty.