Skip to content

proxyBaseURL default should not start with /api #38

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

Closed
MickL opened this issue Nov 24, 2024 · 6 comments
Closed

proxyBaseURL default should not start with /api #38

MickL opened this issue Nov 24, 2024 · 6 comments

Comments

@MickL
Copy link

MickL commented Nov 24, 2024

IMO the default proxy path should not start with /api because this might conflict with existing paths or existing proxy rules. E.g. I proxy everything that starts with '/api' to my external API.

I use a lot of modules in my project and none is using the '/api' prefix so I never had a problem until now. E.g. nuxt-icon uses /_nuxt_icon, nuxt-images goes to /_ipx for ipx provider.

Following the consistency of other modules, my suggestion would be to change the default to /_plausible_event

@johannschopplich
Copy link
Collaborator

johannschopplich commented Nov 25, 2024

I don't think that's the right way to do this. IMHO, Nuxt Icon also uses the /api path:

https://github.com/nuxt/icon/blob/1381039a295dd73681e46cb54af45892bb51c3ca/src/module.ts#L81

    addServerHandler({
      route: `${options.localApiEndpoint || '/api/_nuxt_icon'}/:collection`,
      handler: resolver.resolve('./runtime/server/api'),
    })

@johannschopplich johannschopplich changed the title proxyBaseURL default should not start with /api proxyBaseURL default should not start with /api Nov 25, 2024
@johannschopplich
Copy link
Collaborator

OK, got it. Let' use _plausible as a base. If a user requires the API prefix, he can still add it:

export default defineNuxtConfig({
  plausible: {
    proxy: true,
    proxyBaseEndpoint: '/api/_plausible',
  },
})

@johannschopplich
Copy link
Collaborator

Fixed in 1e229ac.

@MickL
Copy link
Author

MickL commented Nov 25, 2024

Thanks for the quick fix! Just one note: It is now _plausible/api/event instead of _plausible/event :D

@johannschopplich
Copy link
Collaborator

johannschopplich commented Nov 25, 2024

Yes, this is intended. The Plausible Tracker library will always call api/event. But what we can do, is change the API host (instead of https://plausible.io we pass /_plausible as the base host to the library). The rest is handled by the proxy.

@MickL
Copy link
Author

MickL commented Nov 25, 2024

I see, thanks for the info!

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

No branches or pull requests

2 participants