• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Set custom cookies from NodeBB

Scheduled Pinned Locked Moved NodeBB Development
4 Posts 2 Posters 535 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dougsmith1000
    wrote on last edited by
    #1

    I am using a plugin that allows users to auth using my own oAuth system. I figured out that I can not set an HttpOnly cookie across domains from the response header, so I am trying to figure out if there is a hook within NodeBB that will allow me to set a cookie. My oAuth system resides on a different domain. I could duplicate it on the current domain, but would really like to avoid it. Can anyone offer any help?

    1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    wrote on last edited by
    #2

    You can set cookies with res.cookie: https://expressjs.com/en/api.html#res.cookie

    Depending on whether you want that cookie set only on a certain route or on all routes, you might need to register an express middleware.

    1 Reply Last reply
    0
  • D Offline
    D Offline
    dougsmith1000
    wrote on last edited by
    #3

    Thank you @PitaJ . I'm unsure which file in the NodeBB repo to adjust if I want to add a cookie to the response though. I'm fairly new to express rendered templates. Would you recommend me working in the render.js file?

    1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    wrote on last edited by PitaJ
    #4

    You should be able to do it within your plugin. What have you tried?

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development