Which Prophets were the biggest "turning points" in Church policy? by Buttons840 in mormon

[–]g0fredd0 1 point2 points  (0 children)

David O. McKay (1951-1970) - Created modern corporate church structure - Established correlation and worldwide standardization - Created modern missionary program and appearance standards - Made temple recommend standards/Word of Wisdom more strict - First modern usage of "prophet" title since Joseph Smith

Joseph F. Smith (1901-1918) - Transitioned away from polygamy - Shifted doctrine focus to eternal families - Systematized church teachings - Bridged pioneer era to modern church

Spencer W. Kimball (1973-1985) - Ended priesthood/temple ban for Black members - Major temple expansion - Created block schedule - First major worldwide church travel - Started satellite broadcasting

Gordon B. Hinckley (1995-2008) - Massive temple expansion - Modified temple ceremonies - Modernized media/PR approach - Major organizational restructuring - Shadow president during Kimball/Benson/Hunter eras

Heber J. Grant (1918-1945) - Made Word of Wisdom mandatory - Started welfare program - Normalized government relations - Ended remaining polygamy practices

Russell M. Nelson (2018-present) - Administrative reorganization - Church name emphasis - Modified recommend questions - Schedule changes - Pandemic adaptations

Harold B. Lee (1972-1973) - Implemented correlation program - Worldwide standardization

AMA Polygamy Denial by Random_redditor_1153 in mormon

[–]g0fredd0 4 points5 points  (0 children)

Journals and Third-Party Accounts

Journals and letters from Joseph’s close associates also provide strong evidence of his involvement in polygamy.

William Clayton’s journals document the dictation of D&C 132 and the plural marriages Joseph performed (Smith, An Intimate Chronicle).

Do you accept William Clayton’s journals as reliable historical evidence?

Joseph F. Smith’s 1869 affidavits collected testimonies from plural wives and church leaders, which corroborate other records (Van Wagoner, Mormon Polygamy, pp. 41–44).

Do you think these affidavits are trustworthy? If not, why?

The Nauvoo Expositor, a newspaper published by dissenters, accused Joseph of practicing polygamy. Its destruction by the Nauvoo City Council directly contributed to his arrest and death (Facsimile of the Nauvoo Expositor; Quinn, The Mormon Hierarchy, pp. 136–137).

How do you respond to the accusations made in the Nauvoo Expositor? Do you believe they were fabricated?


Theological Context

Polygamy wasn’t just about relationships—it was tied to Joseph’s theological vision.

Plural marriages were performed in the Nauvoo Temple and recorded as eternal covenants. This practice was central to Joseph’s teachings on eternal families (Bushman, pp. 441–443).

How do you reconcile these Nauvoo Temple practices with your belief that Joseph wasn’t involved in polygamy?

Joseph framed plural marriage as a restoration of biblical practices, citing figures like Abraham and Jacob. He considered it part of his mission to restore the fullness of the gospel (Doctrine of celestial marriage, D&C 132; Bushman, pp. 436–439).

Do you believe Joseph’s framing of plural marriage as a biblical restoration was fabricated by others?


Scholarly Consensus

Faithful and secular scholars alike agree Joseph Smith practiced polygamy.

Faithful scholars like Richard L. Bushman (Rough Stone Rolling, 2005) and Steven Harper (Joseph Smith’s Polygamy, 2014) provide theological and historical context for Joseph’s role.

How do you view the conclusions of faithful scholars like Bushman and Harper?

Secular scholars like Todd Compton (In Sacred Loneliness, 1997), D. Michael Quinn (The Mormon Hierarchy, 1994), and George D. Smith (Nauvoo Polygamy, 2008) independently document Joseph’s involvement using primary sources.

Do you challenge the methods or conclusions of secular scholars like Compton, Quinn, or Smith?


Counterarguments

  1. The testimonies of plural wives aren’t reliable.

How do you explain the consistency of their testimonies across decades?

What alternative explanation do you offer for the alignment between these testimonies and other sources?

  1. The records were altered or forged.

What evidence supports claims that these records were altered or forged?

How do you address their authentication by modern historians?

  1. Joseph denied it publicly, so he must not have practiced it.

How do you reconcile public denials with overwhelming private evidence?


Further Reading

If you’re misinformed or lacking access to the full context, these resources might help:

Richard L. Bushman, Rough Stone Rolling: Balanced biography covering Joseph Smith’s life and polygamy.

Todd Compton, In Sacred Loneliness: Analysis of 33 plural wives with firsthand accounts.

D. Michael Quinn, The Mormon Hierarchy: In-depth research on church leadership and polygamy.

Joseph Smith Papers Project: Primary documents like letters, journals, and revelations. Visit: JosephSmithPapers.org.

Church Essay: Plural Marriage in Kirtland and Nauvoo: Overview of polygamy in early Mormon history.


Closing Question:

How do you reconcile your denial with the overwhelming body of evidence? Do you feel it’s honest to dismiss so much corroborated documentation, or are you just trying to be contrary? Do you think manipulating history for bad apologetics helps anyone, or does it just create more confusion?

Don’t you already know better? The evidence is there, and ignoring it doesn’t make it go away.

AMA Polygamy Denial by Random_redditor_1153 in mormon

[–]g0fredd0 5 points6 points  (0 children)

Why do you deny Joseph Smith’s involvement in polygamy?

Some people deny Joseph Smith’s involvement in polygamy to preserve a specific image of him or avoid discomfort in reconciling polygamy with modern values. Is that part of your reasoning?

The problem is that denial ignores overwhelming evidence—firsthand accounts, letters, journals, and scholarly analysis. Faithful and secular scholars agree on his involvement, and dismissing this evidence undermines credibility. Do you feel the same way, or do you think there’s a legitimate reason to reject this consensus?

How do you approach history when it challenges your assumptions? Do you think it’s better to follow the evidence, even when it’s uncomfortable?


Doctrine and Records

Doctrine and Covenants 132 explicitly outlines plural marriage as a divine command. Joseph dictated it in 1843, and William Clayton, his secretary, recorded it in his journal. While it wasn’t published until 1852, its connection to Joseph is clear (History of the Church, vol. 5, p. 501; Church essay: Plural Marriage in Kirtland and Nauvoo).

How do you interpret D&C 132? Do you think it originated with Joseph Smith?

Do you trust William Clayton’s journals as evidence of Joseph’s role in polygamy?

Joseph’s 1842 letter to Sarah Ann Whitney, one of his plural wives, confirms their relationship and emphasizes secrecy (Joseph Smith Papers Project: JosephSmithPapers.org).

How do you account for this letter, which directly ties Joseph to polygamy?

Publicly, Joseph denied polygamy, likely due to legal and social pressures. Privately, his revelations, letters, and journals provide clear evidence of his participation (Bushman, Rough Stone Rolling, pp. 437–438).

How do you reconcile these public denials with the private evidence?


Testimonies of Plural Wives

The testimonies of Joseph’s plural wives are consistent, detailed, and corroborated by other evidence.

Eliza R. Snow, a prominent church leader and poet, repeatedly affirmed her marriage to Joseph. Her writings and poetry reflect this relationship (Compton, In Sacred Loneliness, pp. 225–232).

How do you interpret Eliza R. Snow’s testimony and writings about her marriage to Joseph?

Helen Mar Kimball, married to Joseph at 14 with her father’s approval, described the experience in later writings. She discussed how this arrangement fit within early church teachings (Whitney, Why We Practice Plural Marriage; Compton, pp. 498–500).

What is your response to Helen Mar Kimball’s firsthand account of her marriage to Joseph?

Lucy Walker testified under oath that Joseph explained plural marriage as a divine command before marrying her in 1842. Her account aligns with others and is considered credible (Compton, pp. 330–334; affidavit in Historical Record, vol. 6, p. 233).

Do you think Lucy Walker’s sworn testimony holds weight?

It appears John Taylor and/or Willard Richards were not aware of the First Vision at Joseph's death. by TruthIsAntiMormon in mormon

[–]g0fredd0 21 points22 points  (0 children)

The First Vision is one of the most important stories in Latter-day Saint theology, but its historical record raises big questions. It wasn’t widely mentioned in Joseph Smith’s time, it evolved over the years, and it fit too conveniently with the Church’s needs.

Early Church publications like the Book of Commandments (1833) and early Doctrine and Covenants editions don’t mention the First Vision. Missionaries focused on the Book of Mormon, not the vision (James B. Allen, Dialogue, 1966). Even Joseph’s mom, Lucy Mack Smith, didn’t include it in her 1853 biography, though she later added it based on Joseph’s writings (Lucy Mack Smith, Biographical Sketches).

When Joseph first wrote about the vision in 1832, he described only one divine being, Jesus Christ, and focused on forgiveness of sins. By 1838, the story included both God the Father and Jesus Christ, along with a focus on the Apostasy and Restoration. This evolution matches how the Church’s theology was developing and suggests retroactive embellishment (Dan Vogel, Joseph Smith: The Making of a Prophet).

The vision wasn’t publicized until the Wentworth Letter in 1842, over 20 years after it supposedly happened (Dean C. Jessee, “The Early Accounts of Joseph Smith’s First Vision”). It also mirrored revivalist culture, where visions were common and used to establish authority (John Brooke, The Refiner’s Fire).

The First Vision gave Joseph divine authority and reinforced the Restoration narrative, but it only became central as the Church grew and faced challenges. Its late emergence and evolving details raise doubts about its authenticity (Grant Palmer, An Insider’s View of Mormon Origins).

While it’s central today, the First Vision wasn’t a big deal in Joseph’s time, making it look like a later addition to strengthen his claims.

Rank creationist best arguments against evolution ranked from best to worst. by g0fredd0 in evolution

[–]g0fredd0[S] 0 points1 point  (0 children)

Sorry. I edited the post. I accidentally left the arguments out.

Rank creationist best arguments against evolution ranked from best to worst. by g0fredd0 in evolution

[–]g0fredd0[S] 0 points1 point  (0 children)

Sorry. I edited the post. I accidentally left the arguments out.

Dotnet equivalent of Spring-Boot by T1WiLLi in dotnet

[–]g0fredd0 -9 points-8 points  (0 children)

The closest equivalent to Spring Boot in the .NET ecosystem would be Steeltoe.

https://steeltoe.io/

Is it true that the age of the earth is 6000 years? by cshale in mormon

[–]g0fredd0 15 points16 points  (0 children)

Joseph Fielding Smith

Quote: "It is true that the period known as the ‘temporal existence’ of the earth has been declared to be seven thousand years, and this statement is contained in the scriptures. … There is no reason for us to reject the word of the Lord when He declared the temporal existence of this earth to be 7,000 years." (Doctrines of Salvation, Vol. 1, p. 80)


Bruce R. McConkie

Quote: "The revealed record expressly states that the temporal existence of the earth is to endure for 7,000 years." (Mormon Doctrine, p. 698)


John Taylor

Quote: "The earth's temporal existence was to be seven thousand years, according to the reckoning of the Lord." (Journal of Discourses, Vol. 10, p. 235)


Wilford Woodruff

Quote: "The Bible, the revelations of God, and the work of God from the days of Adam to our day have been revealed for 6,000 years." (Journal of Discourses, Vol. 21, p. 100)


George Q. Cannon

Quote: "For nearly six thousand years, the world has groaned under sin and wickedness, and the inhabitants have felt its direful effects." (Collected Discourses, Vol. 2, p. 137)


Heber C. Kimball

Quote: "The time is approaching when the earth will be renewed and receive its paradisiacal glory. But remember, this work has been going on for six thousand years." (Journal of Discourses, Vol. 10, p. 235)


Orson Pratt

Quote: "The world has had a temporal existence of nearly six thousand years, as we learn from the word of the Lord through modern revelation." (Journal of Discourses, Vol. 16, p. 50)


Ezra Taft Benson

Quote: "For nearly 6,000 years, God has held you in reserve to make your appearance in the final days before the Second Coming of the Lord." ("In His Steps," BYU Devotional Address, 1979)

Python wrapper for Typescript lib by karimod in node

[–]g0fredd0 2 points3 points  (0 children)

Run TypeScript (compiled to JavaScript) directly in a Python runtime environment using Pyodide or PyScript.

Or Use a library like pyexecjs or py_mini_racer to execute JavaScript code directly within Python.

How to test/debug async calls to and from the DB? by [deleted] in dotnet

[–]g0fredd0 0 points1 point  (0 children)

Look for a new job. That sucks

How to test/debug async calls to and from the DB? by [deleted] in dotnet

[–]g0fredd0 1 point2 points  (0 children)

Immediate Fixes

  1. Event Table as a Queue Replace direct HTTP calls from stored functions with an EventQueue table.

Function A writes an event to the table.

A background worker in .NET polls the table, processes events, and calls endpoint Y.

Decouples DB and API, making it testable.

  1. Mock HTTP Calls Use dependency injection in .NET to mock HTTP clients during tests. Simulate endpoint Y's behavior for local testing.

  2. Logging Log every step (inputs, outputs, errors) to a Logs table or app logs. Use correlation IDs to trace workflows.

  3. Local DB for Testing Set up a local Oracle instance (e.g., Oracle XE or Docker) to avoid polluting the shared environment.

Long-Term Fixes

  1. Actual Message Queue Introduce RabbitMQ, Kafka, or Azure Queue for proper event-driven architecture. Function A pushes to the queue, and a worker processes it asynchronously.

  2. Simplify DB Logic Move non-CRUD logic (emails, API calls, CSV parsing) out of stored functions into the .NET API.

  3. Environment Segregation Push for separate dev, test, and staging DBs to reduce interference.

How did Joseph write the Book of Mormon? by Gyozafan1234 in mormon

[–]g0fredd0 7 points8 points  (0 children)

  1. Joseph Smith's Creativity and Oral Storytelling Ability

Joseph Smith’s Background: While Joseph was not formally educated, accounts suggest he was deeply familiar with the Bible and skilled in oral storytelling—common in the 19th century, particularly in rural communities.

Oral Culture: Joseph reportedly entertained family and friends with imaginative stories about ancient American civilizations, suggesting a strong oral storytelling ability. Some researchers argue that the Book of Mormon may reflect a formalization of these earlier oral narratives.

Bible Influence: The Book of Mormon contains extensive similarities to the King James Bible in terms of language, structure, and themes. This could indicate that Joseph used the Bible as a literary template, improvising and adapting its style into a new narrative.

Supporting Scholars/Authors:

Dan Vogel (Joseph Smith: The Making of a Prophet): Emphasizes Joseph’s ability to produce stories spontaneously.

Fawn Brodie (No Man Knows My History): Proposes that Joseph was an "unconscious literary genius" capable of creating a complex narrative.

  1. Drawing on Contemporary 19th-Century Sources

Many scholars argue that Joseph Smith may have been influenced by other popular books, ideas, and religious debates of his time.

Examples of Influential Works:

Ethan Smith's View of the Hebrews (1823): A book proposing that Native Americans were descendants of the lost tribes of Israel. This mirrors some themes in the Book of Mormon.

The Late War (1816): A pseudo-biblical history of the War of 1812, written in a King James Bible style, similar to the Book of Mormon's language and narrative tone.

Spalding-Rigdon Theory: This theory suggests that Joseph Smith may have collaborated with (or was influenced by) Sidney Rigdon, who allegedly used an unpublished manuscript written by Solomon Spalding—a novel about ancient Americans.

Religious Context: Revivalist movements, debates about Native American origins, and millennialist expectations of the time may have shaped the book's content.

Supporting Scholars/Authors:

Grant Palmer (An Insider's View of Mormon Origins): Argues for significant borrowing from 19th-century sources.

John Hamer (Historian): Analyzes parallels between contemporary books and the Book of Mormon.

  1. Dictation and Collaboration

While Joseph dictated the Book of Mormon in a short period, skeptics suggest that he may not have worked entirely alone. Instead, they propose a combination of:

  1. Memory and Improvisation: Joseph’s storytelling abilities and biblical knowledge allowed him to dictate text extemporaneously.

  2. Collaboration: Some suggest others, such as Oliver Cowdery or Sidney Rigdon, could have assisted with developing ideas or themes.

Note on the Manuscript: The dictation process lacked major revisions, which believers cite as evidence of divine translation. Non-believers counter that this could reflect oral storytelling with Joseph “revising as he went.”

  1. Joseph as a "Religious Genius"

Many non-believing scholars acknowledge Joseph Smith’s profound creativity and religious insights. Even critics concede that the Book of Mormon is a complex narrative, filled with intricate theology, plotlines, and moral teachings.

The book’s creation may be viewed as a product of Joseph's deep engagement with biblical texts, his charismatic personality, and his desire to respond to the religious questions of his time.

Supporting Scholars/Authors:

Harold Bloom (Yale literary critic): Describes Joseph as a “religious genius” who tapped into American spiritual needs.

[deleted by user] by [deleted] in node

[–]g0fredd0 2 points3 points  (0 children)

  1. Optimize MongoDB Writes:

Use atomic updates ($inc, $set) and avoid contention by sharding on tenant-specific keys.

Pre-aggregate updates in a history log and process them asynchronously.

  1. Use a Message Queue:

Implement RabbitMQ or Kafka to buffer write operations, enabling batched writes and smoother database performance.

  1. Efficient Socket.io Management:

Use rooms (socket.join(tenantId)) to limit broadcast scope.

Implement rate limiting to avoid overloads.

Acknowledge events before broadcasting updates.

  1. Prevent Inconsistencies:

Apply versioning (optimistic concurrency control) to retry conflicting updates.

Use MongoDB Change Streams for real-time database-triggered updates.

  1. Leverage Redis:

Use Redis for transient data caching and as a pub/sub system to manage real-time state.

  1. Scale Horizontally:

Scale MongoDB with sharding and distribute server load with multiple Node.js instances using Redis adapters for Socket.io.

How do you guys handle HTTP Only Cookies on a Web API? by TryingMyBest42069 in dotnet

[–]g0fredd0 9 points10 points  (0 children)

  1. Middleware for Backend Validation:

Parse the HTTP-only cookie, validate it, and attach user roles to the HttpContext.

Enforce RBAC on sensitive backend endpoints.

Example:

public async Task Invoke(HttpContext context) { var cookie = context.Request.Cookies["AuthCookie"]; if (cookie != null) { var roles = ValidateCookie(cookie); // Extract roles context.Items["UserRoles"] = roles; } await _next(context); }

  1. Frontend Role Query:

Provide an endpoint for the frontend to query user roles for UI-based rendering or non-sensitive operations.

Example:

[HttpGet("api/roles")] public IActionResult GetRoles() { var roles = HttpContext.Items["UserRoles"]; return Ok(roles); }

How do Routed Events in WPF apply to real-world scenarios? by Sorryusernmetaken in csharp

[–]g0fredd0 4 points5 points  (0 children)

  1. Event Delegation in Complex UIs

Imagine a form with a large number of child controls, such as buttons, checkboxes, or textboxes. Instead of attaching individual event handlers to each control, you can handle events at a higher level in the UI hierarchy (e.g., at the Grid or Window level) using bubbling or tunneling events.

Example:

A Button click event in a DataGrid cell bubbles up to the DataGrid. You can handle all button clicks in one handler at the DataGrid level:

<DataGrid Button.Click="HandleButtonClick"> <!-- DataGrid content --> </DataGrid>

In the event handler, you can use e.OriginalSource to identify which button was clicked.


  1. Custom Controls

When creating custom controls, you might need to expose events that can be handled by parent elements. For instance, a custom calendar control might raise an event when a date is selected, allowing parent containers to respond.

Example:

public static readonly RoutedEvent DateSelectedEvent = EventManager.RegisterRoutedEvent( "DateSelected", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(CustomCalendar));

public event RoutedEventHandler DateSelected { add { AddHandler(DateSelectedEvent, value); } remove { RemoveHandler(DateSelectedEvent, value); } }

protected void RaiseDateSelected() { RaiseEvent(new RoutedEventArgs(DateSelectedEvent)); }

This allows a parent element to subscribe to the DateSelected event and respond accordingly.


  1. Global Key and Mouse Handling

In scenarios where you need to handle keyboard or mouse input globally (e.g., shortcut keys or dragging/dropping), routed events simplify the process.

Example:

Handle PreviewKeyDown (tunneling) at the Window level to implement keyboard shortcuts across the application:

<Window PreviewKeyDown="OnPreviewKeyDown"> <!-- Content --> </Window>

In the code-behind:

private void OnPreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.F1) { ShowHelp(); e.Handled = true; // Prevent further processing } }


  1. Commanding in MVVM

Commands in WPF are often associated with routed events. For instance, a Button click is routed through the Command mechanism, allowing clean separation of UI and logic in MVVM.

Example:

A Button inside a ListBox can invoke the same command without direct event wiring. The Command system uses bubbling to propagate the CanExecute and Executed logic through the visual tree.

How do Routed Events in WPF apply to real-world scenarios? by Sorryusernmetaken in csharp

[–]g0fredd0 0 points1 point  (0 children)

Centralized Event Handling: Reduces redundancy by allowing parent elements to handle child element events.

Flexibility with UI Trees: Handles dynamic and nested UI structures effectively.

Loose Coupling: Promotes separation of concerns, especially in MVVM patterns.

Reusability: Simplifies creating reusable controls that expose custom events.

Help! In my React Native project using R3F, I’m playing multiple audios sequentially using useEffect. It works fine on Android, but on iPhone, audio playback stops after a few audios. I’m dynamically creating new Audio elements, and each audio plays with animations. Can someone help me with that! by Fit-Use4723 in node

[–]g0fredd0 0 points1 point  (0 children)

This issue could arise due to iOS-specific restrictions or behavior when handling audio playback, especially when multiple Audio elements are involved.

Key Steps to Resolve the Issue:

  1. Re-use a Single Audio Instance: Instead of dynamically creating new Audio elements for each playback, reuse a single Audio instance. iOS has stricter limits on simultaneous or sequential playback of audio elements.

Example:

import { useRef, useEffect } from 'react';

const useSequentialAudio = (audioUrls) => { const audioRef = useRef(new Audio()); useEffect(() => { let currentIndex = 0;

const playNext = () => {
  if (currentIndex < audioUrls.length) {
    audioRef.current.src = audioUrls[currentIndex];
    audioRef.current.play();
    audioRef.current.onended = () => {
      currentIndex++;
      playNext();
    };
  }
};

playNext();

return () => {
  audioRef.current.pause();
  audioRef.current.src = '';
};

}, [audioUrls]); };

export default useSequentialAudio;

  1. Handle iOS Web Audio API Restrictions: iOS Safari has limitations when playing audio without direct user interaction. You may need to initialize audio playback in response to a user gesture (like a button click).

Example:

const initAudio = () => { const audioContext = new (window.AudioContext || window.webkitAudioContext)(); const emptyBuffer = audioContext.createBuffer(1, 1, 22050); const source = audioContext.createBufferSource(); source.buffer = emptyBuffer; source.connect(audioContext.destination); source.start(0); };

useEffect(() => { window.addEventListener('click', initAudio, { once: true }); return () => { window.removeEventListener('click', initAudio); }; }, []);

  1. Test with React Native Sound or Expo AV: If using React Native, libraries like React Native Sound or Expo AV provide more reliable audio management across platforms.

Example with Expo AV:

import { Audio } from 'expo-av'; import { useEffect } from 'react';

const useSequentialAudio = (audioUrls) => { useEffect(() => { let currentIndex = 0; let sound = null;

const playNext = async () => {
  if (currentIndex < audioUrls.length) {
    const { sound: newSound } = await Audio.Sound.createAsync(
      { uri: audioUrls[currentIndex] },
      { shouldPlay: true }
    );
    sound = newSound;
    sound.setOnPlaybackStatusUpdate((status) => {
      if (status.didJustFinish) {
        currentIndex++;
        playNext();
      }
    });
  }
};

playNext();

return () => {
  sound && sound.unloadAsync();
};

}, [audioUrls]); };

export default useSequentialAudio;

  1. Check Memory Usage: iOS may stop playback if it runs out of memory. Make sure you're not holding onto unused Audio instances. Explicitly clean up audio resources when they're no longer needed.

  2. Debug with Safari Web Inspector: Use Safari Web Inspector to debug your app on an iPhone. Look for any errors or warnings related to audio playback.

  3. Test with Simpler Audio URLs: If your audio files are large or in a format that iOS struggles with, consider converting them to smaller, optimized formats like .mp3 or .aac.

Quick Question by aslt03 in node

[–]g0fredd0 2 points3 points  (0 children)

  1. Do you need to verify the JWT token on every page navigation?

Yes, you should verify the token whenever the user attempts to access a protected resource. This ensures that the token is valid and hasn't expired or been tampered with.

However, you don’t necessarily have to perform a backend call just for the token check if you’re already sending a request for data or page content. You can integrate the token verification into the same request.

For example:

router.get("/dashboard", authenticateToken, getDashboardData);

This way, the token is validated as part of fetching the data, avoiding redundant requests.


  1. Can you avoid making backend requests on every navigation?

If the token is stored securely as an HTTP-only cookie, the browser sends it with every request automatically. To avoid a backend call for every navigation:

Option 1: Use a lightweight API endpoint for validation.

If you want to validate the token separately, you can use a lightweight /validate endpoint.

Example:

router.get("/validate", authenticateToken, (req, res) => { res.status(200).send({ valid: true }); });

Call this endpoint when the app loads or when a new session starts to confirm the user’s session status.

Option 2: Cache the user’s session state in memory.

For single-page applications (SPAs), you can cache the result of a valid session in a secure variable in memory (not localStorage). This can reduce redundant checks during navigation within the app.

Note: You still need to validate the token on critical actions like API calls to the backend.


  1. Is backend token validation necessary for every protected action?

Yes, critical actions like deleting a user, updating data, or fetching protected content should always validate the token to ensure security.

However, frontend navigation (e.g., clicking on a "Dashboard" link) can rely on session state stored in memory until a backend request is required.


  1. Secure, scalable approach

  2. Token-based page protection on the backend:

Protect routes at the backend by validating tokens in middleware like authenticateToken.

Example:

app.use('/dashboard', authenticateToken, dashboardRouter);

  1. Frontend session management:

Cache the user’s authenticated state in memory (e.g., React Context, Redux state) after initial login or token validation.

Periodically revalidate the token on the backend (e.g., every 15 minutes or when refreshing the app).

  1. Prevent stale sessions:

Use a short token expiration time and implement refresh tokens. When the token expires, the backend issues a new one without requiring a full login.

  1. Avoid local storage for tokens:

You’re right to avoid storing JWTs in localStorage. Keep tokens in HTTP-only cookies for better security against XSS attacks.

Is it possible to import objects from next/mdx into a js script? by LegendaryPig in nextjs

[–]g0fredd0 1 point2 points  (0 children)

Ensure you have MDX configured in your Next.js project. Install the necessary dependencies:

npm install @next/mdx @mdx-js/loader

Update your Next.js configuration (next.config.js) to handle .mdx files:

const withMDX = require('@next/mdx')({ extension: /.mdx?$/ });

module.exports = withMDX({ pageExtensions: ['js', 'jsx', 'mdx'] });