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

Add support for res.cookie #101

Closed
geritol opened this issue Aug 27, 2021 · 5 comments
Closed

Add support for res.cookie #101

geritol opened this issue Aug 27, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@geritol
Copy link

geritol commented Aug 27, 2021

res.cookie works in gatsby (eg. res.cookie("test", true, { httpOnly: false }) but does not work on netlify

Steps to reproduce

create a function that set a cookie eg.

export default function handler(req, res) {
  res.cookie("test", true, { httpOnly: false })
  res.redirect("/")
}

Expected behavior

runs and sets cookie locally.
on netlify the function is erroring with

Error when executing function "my-function.js": "res.cookie is not a function"

Can you submit a pull request?

Yes

@geritol geritol added the bug Something isn't working label Aug 27, 2021
@ascorbic
Copy link
Contributor

Sounds good! If you want to open a PR I'm happy to look at it, otherwise I should be able to get to it in a couple of weeks

@geritol
Copy link
Author

geritol commented Aug 27, 2021

@ascorbic I am giving it a try right now.
I am not yet able to run tests yet.

Steps that I have figured out that I could not find documented in CONTRIBUTING.md:

  • I needed to install dependencies in the plugin folder too
  • I needed to install netlify-cli as a dev dependency to the root package

Currently the test command is filing with:

> function-test@1.0.0 build:netlify
> netlify build --offline

internal/modules/cjs/loader.js:834
  throw err;
  ^

Error: Cannot find module '@oclif/command'

Do you have any pointer what the issue could be?
I guess @oclif/command should be a dependency to netlify-cli

@geritol
Copy link
Author

geritol commented Aug 27, 2021

if I install netlify cli globally it fails with the following error

> function-test@1.0.0 build:netlify
> netlify build --offline

internal/modules/cjs/loader.js:834
  throw err;
  ^

Error: Cannot find module 'update-notifier'

@geritol
Copy link
Author

geritol commented Aug 27, 2021

Uninstalled a reinstalled netlify cli globally and it solved the above issue.
Now I am running into
There was a problem loading the local build command. Gatsby may not be installed. Perhaps you need to run "npm install"? Cannot find module 'date-fns/getDayOfYear'

@ascorbic
Copy link
Contributor

ascorbic commented Jan 25, 2022

Looking at the Gatsby docs, there is no mention of support for res.cookie(). It seems that because the dev server uses Express, those are supported by accident, but as this is not documented and may not work in production. For that reason I don't think we should add support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants