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

Extend assetPrefix for global prefixing #4146

Closed
zvictor opened this issue Apr 12, 2018 · 2 comments
Closed

Extend assetPrefix for global prefixing #4146

zvictor opened this issue Apr 12, 2018 · 2 comments

Comments

@zvictor
Copy link

zvictor commented Apr 12, 2018

It has been great to have assetPrefix in our app. With few modifications we are able to serve nextjs next to a meteor app, served in the same domain but with a specific prefix:

mydomain.com/next/* --> nextjs
mydomain.com/* --> old meteor

The problem

In the scenario described above, we make use of assetPrefix not only for assets but for the whole application. As consequence:

  1. It feels hacky to call it assetPrefix when we are actually prefixing everything.
  2. As it was intended, the helpers from next/asset are only useful for proper assets. Anything outside of /static that needs to be prefixed can't be done this way.
  3. The assetPrefix is not accessible from next/config. If you want to reuse assetPrefix e.g. when prefixing your routes, you can't.

Desired behaviour

↳ Option 1 (quick and dirty):

give access to assetPrefix, allowing devs to keep misusing it as a global prefix.

import { getAssetPrefix } from 'next/asset'

myRouter.setPrefix(getAssetPrefix())

↳ Option 2:

create a new prefix to cover the use case I described.

import { globalPrefix } from 'next/config'

myRouter.setPrefix(globalPrefix)

...

express().use(globalPrefix, myRouter)

assetPrefix would still exist, but globalPrefix would be its default value.

@tlenex
Copy link

tlenex commented May 9, 2018

Struggling with this too, seems like we have to make a custom server with all routes just for server route prefix support.

EDIT:
#3332 seems like a solution, but we need to get this merged

@timneutkens
Copy link
Member

Tracking this here: #4998

@lock lock bot locked as resolved and limited conversation to collaborators Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants