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

Next 13 beta RCC fetch with useEffect not working with public directory #42762

Open
1 task done
TomasHubelbauer opened this issue Nov 10, 2022 · 2 comments
Open
1 task done
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.

Comments

@TomasHubelbauer
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64
Binaries:
  Node: 19.0.0
  npm: 8.19.2
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 13.0.3-canary.3
  eslint-config-next: 13.0.2
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

next export

Describe the Bug

I am using Next 13 beta with the app API (no pages routes) and I am hoping to build a component which pulls text from a TXT file in the public directory into its children. Here's the code:

'use client';

import Link from 'next/link';
import { useEffect, useState } from 'react';

export default function About() {
  const [text, setText] = useState('');
  useEffect(() => {
    void async function () {
      const response = await fetch('/rcc-useEffect-test.txt');
      const text = await response.text();
      setText(text);
    }()
  }, []);

  return (
    <>
      <header>
        <Link href="">« Home</Link>
      </header>
      {text}
    </>
  );
}

Unfortunately I am getting this error when I run next build && next export:

PageNotFoundError: Cannot find module for page: /rcc-useEffect-test

I am guessing next export is not fully upgraded to handle the app Next API yet?

Expected Behavior

I would expect Next to build and bundle the application for static file server (such as GitHub Pages) deployment.

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://github.com/TomasHubelbauer/next-13-ssg

To Reproduce

npm install
npm run build

Note that build is patched to be next build && next export so the error should come up.

@TomasHubelbauer TomasHubelbauer added the bug Issue was opened via the bug report template. label Nov 10, 2022
@TomasHubelbauer
Copy link
Author

Note, this issue is also happening when SSGing RSC route. See #42760 for details. In that case, the issue behaves a bit differently in that instead of the route path being reported as the issue, the main route / landing page path is actually being reported as problematic.

@vercel-release-bot
Copy link
Collaborator

This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.

@vercel-release-bot vercel-release-bot added the stale The issue has not seen recent activity. label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.
Projects
None yet
Development

No branches or pull requests

2 participants