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

chore: migrate api routes from pages to app #1266

Merged
merged 4 commits into from
Oct 15, 2024
Merged

Conversation

rmonnier9
Copy link
Contributor

@rmonnier9 rmonnier9 commented Oct 11, 2024

  • Migration
  • Zones impactées : api/auth/agent-connect, api/auth/france-connect.
  • Détails :
    • Migration sur App Router

Closes #1267

Next thing : connexion pages migration in another PR (this one is required before merging agent habilitation PR)

@rmonnier9 rmonnier9 force-pushed the migration-pages-to-app branch 4 times, most recently from 82b817d to db34000 Compare October 11, 2024 11:28
Copy link
Contributor

@XavierJp XavierJp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it very relevant to migrate this code to the app router as it is core code.

@XavierJp
Copy link
Contributor

Could not make it work, both AgentConnect and FranceConnect does not work in local. FranceConnect might be unrelated to your changes though

@rmonnier9
Copy link
Contributor Author

rmonnier9 commented Oct 14, 2024

Could not make it work, both AgentConnect and FranceConnect does not work in local. FranceConnect might be unrelated to your changes though

I fixed it.

When using NextResponse.redirect, full url must be used.
There is a builtin function in nextjs that allows us to use path ("redirect" from next/navigation) but it throws errors in its normal behavior (to stop rendering a server component for example). This behaviour messes up with our try catch.
I created a redirectTo function that creates the url.

From the nextjs doc:
image

chore: use folder with route.ts files

fix: migrate back to pages router download/espace-agent/documents/

fix: separate types from routes files

fix: use full url for redirect in app/api

fix
app/api/auth/utils.ts Outdated Show resolved Hide resolved
@XavierJp XavierJp merged commit 6c03914 into main Oct 15, 2024
9 checks passed
@XavierJp XavierJp deleted the migration-pages-to-app branch October 15, 2024 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate auth api from pages to app
2 participants