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

[Bug?]: ts/js files placed inside of web/src are getting served instead of serving the proper route #9740

Open
1 task
suzdalnitski opened this issue Dec 21, 2023 · 5 comments
Labels
bug/needs-info More information is needed for reproduction topic/router-&-navigation topic/web

Comments

@suzdalnitski
Copy link
Contributor

suzdalnitski commented Dec 21, 2023

What's not working?

I've added auth.tsx to web/src. I also have an /auth route. However, going to localhost:8910/auth serves the raw javascript (ie loads the page), instead of simply updating the route within the frontend app.

This seems to be related to this Vite issue: vitejs/vite#3502

I'm not sure if this can be fixed on the Redwood side, but until Vite fixes this issue, it may be worthwhile to add this to documentation (ie avoid having the same name for a file in web/src and a route).

How do we reproduce the bug?

  • Add a file web/src/auth.tsx
  • Also have a route for /auth (this probably is optional)
  • Try going to localhost:8910/auth

What's your environment? (If it applies)

No response

Are you interested in working on this?

  • I'm interested in working on this
@suzdalnitski suzdalnitski added the bug/needs-info More information is needed for reproduction label Dec 21, 2023
@jtoar
Copy link
Contributor

jtoar commented Dec 22, 2023

Hey @suzdalnitski, I'm not totally sure what the issue you're facing is, but there's a detail wrong in your reproduction that's probably leading to problems.

If you want to add a new route to your web app that's accessible at http://localhost:8910/auth, you'll have to 1) add a new <Route> to the web/src/Routes.tsx file and 2) make a new page in web/src/pages (the page generator does both those things for you: yarn rw g page auth).

It looks like you've added the file to web/src/; the router won't know to pick it up there. Let me know what I'm missing though if that's not the problem!

@suzdalnitski
Copy link
Contributor Author

Hey @jtoar, I was actually setting up authentication with Supertokens. I've ran yarn rw setup auth supertokens. It has generated auth.tsx, and has updated Routes.tsx.

You're correct, there's no auth page, because Supertokens doesn't come with a Redwood Page.

Routes has this instead:

const Routes = () => {
  if (canHandleRoute(PreBuiltUI)) {
    return getRoutingComponent(PreBuiltUI)
  }

  return (
    <Router useAuth={useAuth}>
      <Set wrap={AppLayout}>
        <Route path="/" page={HomePage} name="home" />
      </Set>

      <Route notfound page={NotFoundPage} />
    </Router>
  )
}

@Tobbe
Copy link
Member

Tobbe commented Dec 26, 2023

@suzdalnitski Thanks for reporting this (and the other issues you've reported!) 🙏

Do you see this issue with both yarn rw dev and yarn rw build && yarn rw serve?

Do you think you could provide a step-by-step reproduction? Preferably without involving supertokens if possible.

@suzdalnitski
Copy link
Contributor Author

I've pushed a repo that reproduces the issue: https://github.com/suzdalnitski/redwood-auth-bug

The only things I've done were:

yarn create redwood-app test-app
yarn rw setup auth supertokens
yarn rw dev

Then I opened http://localhost:8910/auth.

@suzdalnitski
Copy link
Contributor Author

Thanks for reporting this (and the other issues you've reported!) 🙏

It's mutual, thanks for the fast response time! It's a pleasure contributing to an open-source project that is so fast to react (I really dislike contributing to open-source projects that take ages to get back).

dthyresson added a commit that referenced this issue Dec 27, 2023
This PR addressed the issues dicussed in
#9753 and
#9740.

---------

Co-authored-by: David Thyresson <dthyresson@gmail.com>
Co-authored-by: Rishabh Poddar <rishabh.poddar@gmail.com>
Tobbe pushed a commit that referenced this issue Jan 1, 2024
This PR addressed the issues dicussed in
#9753 and
#9740.

---------

Co-authored-by: David Thyresson <dthyresson@gmail.com>
Co-authored-by: Rishabh Poddar <rishabh.poddar@gmail.com>
Tobbe pushed a commit that referenced this issue Jan 1, 2024
This PR addressed the issues dicussed in
#9753 and
#9740.

---------

Co-authored-by: David Thyresson <dthyresson@gmail.com>
Co-authored-by: Rishabh Poddar <rishabh.poddar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/needs-info More information is needed for reproduction topic/router-&-navigation topic/web
Projects
None yet
Development

No branches or pull requests

3 participants