<?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: Shubham-Praj</title>
    <description>The latest articles on DEV Community by Shubham-Praj (@shubhampraj).</description>
    <link>https://dev.to/shubhampraj</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F934758%2Fc8c56810-12f4-41f1-8f7a-1991f61bbe74.png</url>
      <title>DEV Community: Shubham-Praj</title>
      <link>https://dev.to/shubhampraj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shubhampraj"/>
    <language>en</language>
    <item>
      <title>Next JS &amp; Node Js Project API call architecture</title>
      <dc:creator>Shubham-Praj</dc:creator>
      <pubDate>Tue, 28 Jan 2025 20:31:00 +0000</pubDate>
      <link>https://dev.to/shubhampraj/next-js-node-js-project-api-call-architecture-3ndg</link>
      <guid>https://dev.to/shubhampraj/next-js-node-js-project-api-call-architecture-3ndg</guid>
      <description>&lt;p&gt;I have a &lt;br&gt;
    Next JS Frontend - 15 (App router)&lt;br&gt;&lt;br&gt;
    Node Server - Express JS 4.21  &lt;/p&gt;

&lt;p&gt;I am trying to create a login system using nextauth, google provider. &lt;/p&gt;

&lt;p&gt;Once the user logs in, I want to make an external API call to my node js auth endpoint, with the nextauth google provider session data to create and entry in my postgres DB.&lt;/p&gt;

&lt;p&gt;Once the entry is created, I want to create a jwt token using that data, which also includes a newly created user_uuid field and set that cookie in next js frontend client side, so every external API request has that jwt token. &lt;/p&gt;

&lt;p&gt;Also on every request I want to refresh the jwt token and again set it as a cookie on client side.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can someone please explain me how to to make the api call from frontend to backend, I have thought of the following solutions (not sure, wheather they are right or not)&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Shall my next js client side api call, hit the next js api/routes endpoint and then it should call the node js backend endpoint ??&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Client should directly call the node js endpoints&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;3.Client should call a service functions (server side), and then those services will call node api endpoints ??&lt;/p&gt;

&lt;p&gt;I am confused rn &lt;/p&gt;

&lt;p&gt;Any help/references/links/leads would be appreciated &lt;/p&gt;

&lt;p&gt;Thanks &lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
  </channel>
</rss>
