+
Skip to content

feat(vite-plugin-nitro): add support for API routes without middleware/proxy #1621

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

Merged
merged 3 commits into from
Feb 25, 2025

Conversation

brandonroberts
Copy link
Member

PR Checklist

Closes #1494

What is the new behavior?

API routes have been defined using the src/server/routes/ folder convention and are prefixed with /api by default. This has some built-in limitations with having to use middleware or a proxy to re-route API in development when mounted under the /api path in the Vite Dev Server, and then re-routed with the Nitro server in the production build.

This also causes issues when using headers and redirects, as they are not applied to the middleware process.

We are moving to using the src/server/routes/api folder to explicitly register API routes, which are treated as full /api/* path routes without using middleware or a proxy. This change looks for an explicitly defined src/server/routes/api folder and falls back to the previous behavior for backward compatibility.

In the future, we will look into adding an automated migration for existing routes to mitigate breaking changes for Analog 2.0.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

[optional] What gif best describes this PR or how it makes you feel?

Copy link

netlify bot commented Feb 25, 2025

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit 98a5c22
🔍 Latest deploy log https://app.netlify.com/sites/analog-docs/deploys/67bd475a23b00000084e47ae
😎 Deploy Preview https://deploy-preview-1621--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 25, 2025

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit 98a5c22
🔍 Latest deploy log https://app.netlify.com/sites/analog-blog/deploys/67bd475a0427cf0009b632e7
😎 Deploy Preview https://deploy-preview-1621--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 25, 2025

Deploy Preview for analog-ng-app ready!

Name Link
🔨 Latest commit 98a5c22
🔍 Latest deploy log https://app.netlify.com/sites/analog-ng-app/deploys/67bd475a390fcb000857614c
😎 Deploy Preview https://deploy-preview-1621--analog-ng-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 25, 2025

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit 98a5c22
🔍 Latest deploy log https://app.netlify.com/sites/analog-app/deploys/67bd475ad0ee1d0008534d7c
😎 Deploy Preview https://deploy-preview-1621--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brandonroberts brandonroberts merged commit a57ef2a into beta Feb 25, 2025
23 of 24 checks passed
@brandonroberts brandonroberts deleted the feat-native-api-routes branch February 25, 2025 05:48
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.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载