<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sowmo0509</title>
    <description>The latest articles on DEV Community by Sowmo0509 (@sowmo0509).</description>
    <link>https://dev.to/sowmo0509</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F623793%2F58254b89-4294-4046-b11a-80d1aaf1a74d.jpeg</url>
      <title>DEV Community: Sowmo0509</title>
      <link>https://dev.to/sowmo0509</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sowmo0509"/>
    <language>en</language>
    <item>
      <title>Setting Up A Cookie From NEXT.JS Back-end</title>
      <dc:creator>Sowmo0509</dc:creator>
      <pubDate>Wed, 02 Nov 2022 12:43:53 +0000</pubDate>
      <link>https://dev.to/sowmo0509/setting-up-a-cookie-from-nextjs-back-end-16kl</link>
      <guid>https://dev.to/sowmo0509/setting-up-a-cookie-from-nextjs-back-end-16kl</guid>
      <description>&lt;p&gt;Hello there, good people! I was literally stuck for a couple of hours on this issue and as a beginner, I am pretty sure most of us will be facing or already faced these kind of cookie setting troubles in NEXT.JS server-side.&lt;/p&gt;

&lt;p&gt;To set a cookie, you just need one package, &lt;code&gt;cookie&lt;/code&gt;. And remember, &lt;u&gt;serious cookies should be sent from the server&lt;/u&gt;. In Express servers, it is pretty easy; just &lt;code&gt;res.cookie()&lt;/code&gt; and you are ready to go. But, in NEXT.JS, you can not just use &lt;code&gt;res.cookie()&lt;/code&gt; directly as far I am concerned. So, here's a solution instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import cookie from "cookie";

// token = your JWT signed token  
res.setHeader("Set-Cookie", cookie.serialize("token", token, COOKIE_OPTIONS));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;"token" : the name of the token.&lt;/li&gt;
&lt;li&gt;token : jwt signed token, STRING, which will be stored inside the token.&lt;/li&gt;
&lt;li&gt;COOKIE_OPTIONS : this is my current cookie option:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const COOKIE_OPTIONS = {
    httpOnly: true,
    secure: process.env.NODE_END !== "development",
    sameSite: "strict",
    maxAge: 3600,
    path: "/",
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how I stored my cookies.&lt;/p&gt;

&lt;p&gt;To remove this cookie:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const COOKIE_OPTIONS = {
    httpOnly: true,
    secure: process.env.NODE_END !== "development",
    sameSite: "strict",
    maxAge: 0, //make sure this is 0
    path: "/",
  };
res.setHeader("Set-Cookie", cookie.serialize("token", "", COOKIE_OPTIONS));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how the whole login and logout cookie process works. Thanks! Hope this will help someone like me! &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Firebase API Key Security Issue – for Custom Sign Up/Login</title>
      <dc:creator>Sowmo0509</dc:creator>
      <pubDate>Sat, 01 May 2021 08:47:46 +0000</pubDate>
      <link>https://dev.to/sowmo0509/firebase-api-key-security-issue-for-custom-sign-up-login-37pb</link>
      <guid>https://dev.to/sowmo0509/firebase-api-key-security-issue-for-custom-sign-up-login-37pb</guid>
      <description>&lt;p&gt;Hello! Hope you're having a good day.&lt;/p&gt;

&lt;p&gt;I was working on a project where I am making a user input form with HTML, JavaScript but when I inspect using Google Chrome, the front-end codes are showing up. All of my firebase Realtime Database API, Key, everything is there, visible.&lt;/p&gt;

&lt;p&gt;I was wondering, if I make a login/sign up page using firebase and JavaScript, someone will be able to steal this database API and create their own HTML form, submit information and then they come back to my site and directly login with what they have, right?&lt;/p&gt;

&lt;p&gt;Is there possibly any way (without React.js .env method) to prevent users from stealing my firebase API codes? &lt;/p&gt;

</description>
      <category>firebase</category>
      <category>javascript</category>
      <category>html</category>
      <category>security</category>
    </item>
  </channel>
</rss>
