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

Possible routing error #1

Open
jfeigel opened this issue May 13, 2013 · 0 comments
Open

Possible routing error #1

jfeigel opened this issue May 13, 2013 · 0 comments

Comments

@jfeigel
Copy link

jfeigel commented May 13, 2013

I downloaded and configured the code in both my local environment (wamp) and with a Heroku developer account using our SalesForce sandbox and when I run the application I get the following error:

TypeError: Cannot call method 'indexOf' of undefined
    at ServerResponse.res.redirect (C:\wamp\www\node\node_modules\express\lib\response.js:403:13)
    at EventEmitter.<anonymous> (C:\wamp\www\node\oauth.js:61:19)
    at EventEmitter.emit (events.js:117:20)
    at EventEmitter.mixin._respond (C:\wamp\www\node\node_modules\restler\lib\restler.js:125:36)
    at EventEmitter.mixin._fireEvents (C:\wamp\www\node\node_modules\restler\lib\restler.js:136:10)
    at IncomingMessage.<anonymous> (C:\wamp\www\node\node_modules\restler\lib\restler.js:118:17)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:895:16
    at process._tickCallback (node.js:415:13)

So after trying to trace it back I ended up editing oauth.js in rest.post.on() to check the state before the redirect:

if(state != undefined) {
    console.log('oauth done - redirecting to '+state);
    res.redirect(state);
}
else {
    console.log('state undefined');
}

Then when I ran the application it was able to render the first page, https://test-sfdc.herokuapp.com/, but when I try to click the link (List of 10 Accounts) I get the following:

oauth done - redirecting to /
state undefined
state undefined
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (http.js:704:11)
    at ServerResponse.res.setHeader (C:\wamp\www\node\node_modules\express\node_modules\connect\lib\patch.js:62:20)
    at next (C:\wamp\www\node\node_modules\express\node_modules\connect\lib\http.js:172:13)
    at Object.callback (C:\wamp\www\node\app.js:32:6)
    at EventEmitter.rest.request.on.on.options.refresh.options.oauth.access_token (C:\wamp\www\node\rest.js:23:13)
    at EventEmitter.emit (events.js:117:20)
    at EventEmitter.mixin._respond (C:\wamp\www\node\node_modules\restler\lib\restler.js:127:12)
    at EventEmitter.mixin._fireEvents (C:\wamp\www\node\node_modules\restler\lib\restler.js:136:10)
    at IncomingMessage.<anonymous> (C:\wamp\www\node\node_modules\restler\lib\restler.js:118:17)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)

Any thoughts?

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

No branches or pull requests

1 participant