Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Fails when --public-url is set #7

Closed
lukechilds opened this issue Apr 23, 2019 · 6 comments
Closed

Fails when --public-url is set #7

lukechilds opened this issue Apr 23, 2019 · 6 comments
Assignees

Comments

@lukechilds
Copy link
Contributor

lukechilds commented Apr 23, 2019

If --public-url https://example.com is set so URLs use absolute paths (a requirement for og:image) then pre-rendering can't load any resources.

Or if the sites already published it will load the (old) live resources not the local resources.

@ABuffSeagull ABuffSeagull self-assigned this Apr 23, 2019
@lukechilds
Copy link
Contributor Author

@ABuffSeagull what do you think the likelihood of getting this working is?

I'm not really sure it's possible without doing some crazy hacks.

One idea I had would be running a local server and serving the dist directory, then running a proxy server proxying --public-url to the local server. Then we could get the puppeteer Chromium instance to use the proxy.

That should work but it's pretty messy. Do you have any better ideas?

@lukechilds
Copy link
Contributor Author

Actually that would then break if they're making any requests to --public-url that aren't static.

e.g https://example.com/api/foo will now get proxied to our local server and fail.

I'm starting to think there just isn't a solution to this.

If you want local prerendering you need to use relative URLs.

@ABuffSeagull
Copy link
Owner

I will have to admit, it took me quite a while to really understand what you're talking about 😆. But yeah, I don't think there's a way you can have both a dynamic request at prerender time, and --public-url set.
The only way I think it could work is if you have your frontend and backend on different hostnames (e.g. https://example.com and https://api.example.com), but obviously that's a pretty specific use case.

@lukechilds
Copy link
Contributor Author

Yeah I think it's probably best to close this issue.

Unfortunately absolute URLs are required for og:image tags. I don't think you can specify an absolute URL for only certain assets with parcel.

I could write a separate plugin that parses HTML for og:image tags and sets an absolute source but that's not a great solution.

@lukechilds
Copy link
Contributor Author

@ABuffSeagull fixed this rather crudely with this plugin: https://github.com/lukechilds/parcel-plugin-ogimage

@ABuffSeagull
Copy link
Owner

I mean hey, whatever gets the job done 😄

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

2 participants