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

publicPath not working when using full URI #578

Closed
bokub opened this issue Jun 10, 2021 · 2 comments
Closed

publicPath not working when using full URI #578

bokub opened this issue Jun 10, 2021 · 2 comments

Comments

@bokub
Copy link

bokub commented Jun 10, 2021

Hi,

In a Nuxt app, for some reason, I need all my assets URIs to include the domain.

For example, in the rendered HTML, instead of having

<script src="/_nuxt/286f58c.js">

I would like to have something like:

<script src="https://mysite.vercel.app/_nuxt/286f58c.js">

or <script src="https://mysite.vercel.app/assets/286f58c.js">


According to the Nuxt doc, I can use the publicPath option for that.

So I tried this config:

  build: {
    publicPath: 'https://mysite.vercel.app/assets/',
  },

And the generated HTML looks good:

<script src="https://mysite.vercel.app/assets/7155d93.js" defer></script>

However, the assets don't exist in the output, and there is a weird empty https: folder instead:

Peek 2021-06-10 11-22

With the following config, the problem is exactly the same, no assets in the output...

  build: {
    publicPath: 'https://mysite.vercel.app/_nuxt/',
  },

Can you confirm that it's a bug and not some misunderstanding from my side?

Thanks a lot 👍

Copy link
Member

@bokub What you would normally do is:

  1. set publicPath as you've done above, to a CDN
  2. build/generate your app
  3. (if building) upload your .nuxt/dist/client folder to that location on your CDN
  4. (if generating) upload the contents of your dist folder to that location on your CDN

However, yes - it was broken because vercel-builder assumed publicPath would be a directory. Should now be fixed in 0.21.3 but note that you will need to set your publicPath to 'https://mysite.vercel.app/_nuxt/' rather than a custom directory.

@bokub
Copy link
Author

bokub commented Jun 10, 2021

Wow, that was fast, and it's working perfectly!

Thanks a lot 👍

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