-
Notifications
You must be signed in to change notification settings - Fork 448
Closed
Labels
type: bugcode to address defects in shipped codecode to address defects in shipped code
Description
- Do you want to request a feature or report a bug?
Report a bug.
- What is the current behavior?
Running "netlify dev" with a local netlify.toml file that includes a [[redirects]] section results in a runtime error.
Warnings while parsing netlify.toml file:
TypeError: Cannot convert object to primitive value
at ~/.nvm/versions/node/v12.16.3/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:15:46
at Array.forEach (<anonymous>)
at parseFile (~/.nvm/versions/node/v12.16.3/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:14:19)
at async parseRules (~/.nvm/versions/node/v12.16.3/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:31:22)
at async createRewriter (~/.nvm/versions/node/v12.16.3/lib/node_modules/netlify-cli/src/utils/rules-proxy.js:68:15)
at async startProxy (~/.nvm/versions/node/v12.16.3/lib/node_modules/netlify-cli/src/commands/dev/index.js:179:20)
at async DevCommand.run (~/.nvm/versions/node/v12.16.3/lib/node_modules/netlify-cli/src/commands/dev/index.js:449:19)
at async DevCommand._run (~/.nvm/versions/node/v12.16.3/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/command.js:42:20)
at async Config.runCommand (~/.nvm/versions/node/v12.16.3/lib/node_modules/netlify-cli/node_modules/@oclif/config/lib/config.js:172:9)
at async Main.run (~/.nvm/versions/node/v12.16.3/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/main.js:21:9)I've installed the netlify-cli into the project in an attempt to debug what is going on. When I step through the code, I'm seeing the error is starting with isPlainObj() in the netlify-redirect-parser/common.js file. If change the function to output what is getting passed...
function isPlainObj(o) {
console.error( "object:", o )
console.error( "typeof o:", typeof o );
console.error( "o.constructor:", o.constructor );
return typeof o == 'object' && o.constructor == Object
}I see the following output:
object: [Object: null prototype] {
from: '/api/*',
to: '/.netlify/functions/:splat',
status: 200
}
typeof o: object
o.constructor: undefinedHopefully that gives you a clue to what is going on.
- If the current behavior is a bug, please provide the steps to reproduce.
- Create a node.js project
- Create a
netlify.tomlfile - Add any
[[redirects]]block to the toml file.
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
status = 200- What is the expected behavior?
Netlify dev server starts without error.
- Local Environment Information
System:
OS: macOS 10.15.4
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 12.16.3 - ~/.nvm/versions/node/v12.16.3/bin/node
npm: 6.14.4 - ~/.nvm/versions/node/v12.16.3/bin/npm
Browsers:
Chrome: 81.0.4044.129
Firefox: 75.0
Safari: 13.1
npmGlobalPackages:
netlify-cli: 2.48.0Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: bugcode to address defects in shipped codecode to address defects in shipped code