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

Access to currently running domain #965

Closed
cfjedimaster opened this issue Feb 25, 2020 · 7 comments
Closed

Access to currently running domain #965

cfjedimaster opened this issue Feb 25, 2020 · 7 comments

Comments

@cfjedimaster
Copy link

While we have access to env variables, it would be nice if we could get access to domain specific values like the current running host and port. While you can get by without this using env variables (if env === 'prod' then my url must be foo.com), I think it could still be useful to have access to.

@coolsoftwaretyler
Copy link

coolsoftwaretyler commented Feb 25, 2020

Where do you need this? On the client side? Build process? Or in the development server with browsersync?

You can grab some useful information from regular ol' DOM APIs on client side. Here's a SO post about getting the host url from the DOM that might be useful.

@cfjedimaster
Copy link
Author

I was imagining server-side. It's definitely available client-side.

@coolsoftwaretyler
Copy link

Have you considered something like path-prefix or some kind of global data variable that you can set at build time? Since Eleventy is an SSG, it's not going to generate server responses like server-side rendering might. This seems like something you could do with a command or env variable at build time.

@cfjedimaster
Copy link
Author

Right, it can be done now. I definitely acknowledge that. And I know it would only be available at build time, ie it wouldn't be dynamic in the build results. I'm just saying it could be handy to be able to access these values.

@zachleat
Copy link
Member

I’m a bit confused what this means? I understand that you’d want to find the host but I’m not sure there is a way to do this without proprietary hooks into web servers or application servers that is probably outside the realm of what we want to dip into.

@cfjedimaster
Copy link
Author

I had imagined we could have access to something like a request object, but... yeah. The more I think about this the more I feel like it's not a good idea. My attempt here was to help out SO questioner (https://stackoverflow.com/questions/60309000/generating-full-urls-on-eleventy-and-netlify/60401857?noredirect=1#comment106866809_60401857), but I think we can do without. Thanks for hearing me out!

@Ryuno-Ki
Copy link
Contributor

Ryuno-Ki commented Mar 3, 2020

Thinking about it …
When I build on one server and deploy it to another one (think CI/CD and CDN system), then the host which builds the file would not be the same as the one serving them …
So I'd go with an environment variable for the build system, which contains information about the target one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants