Generate a complete URL within a Yesod application - web-services

I mean that for example
YC.getUrlRender >>= enact where
enact renderURL = renderURL HomeR
will result in "/", for example, and usually that's what you need. However, I'm trying to crack email verification where the email has to contain the https://yesod.domain.com bit as well so that the user can click on the link to verify the new account. Is it in fact possible to obtain that bit ? In my deployment for example, the Yesod application is behind nginx, with the configuration:
location / {
proxy_pass http://127.0.0.1:3000;
}
so would the Yesod app even know that it was reached via https://myvps.hosting.com ?
Maybe the answer is to pass the information in via nginx, thus:
location / {
proxy_pass http://127.0.0.1:3000?youEnteredVia=https://myvps.hosting.com;
}
although I'd want to use $1 or something to avoid that hard-coded URL, and I don't know how to pick up the value within the Yesod application but I'm sure MS's book has the information somewhere.

This is the entire purpose around having the approot class method, since it's not always possible to determine the correct application root based on the request itself. You may also want to look at ApprootMiddleware.

Related

Django access site name/url in template - views, contexts and settings

(It feels like "best practices" type of question, sorry if these don't belong here)
I'm building a website which has user registration and password reset feature, both of which would send email to the user with a link to click to complete the respective process. While testing on a staging box, I used a dirty workaround in order finish the Proof Of Concept - hardcoded the website address in the template ) Needless to say, I want to fix this sooner rather than later. Searching around, found references to django.contrib.sites, which looks like a possible solution, though one thing bothers me - technically there's but one site, but with two stages, staging and production. I don't want to swim against the current, potentially abusing "sites", where another solution might apply.
I've then considered another approach - add respective URLs to corresponding settings.py files, of which I already have a grasp - one for local, one for staging, and one for prod. The issue here is probably obvious - I don't think it's proper (or possible) to read the settings.py from templates, and trying to keep the solution as simple as possible, I'm using a few standard views, which means I don't have access to the code thereof, to add values to the context. Perhaps I am supposed to override these standard views? Just call 'super' and then add my custom data to the context? But I don't know if this is a right approach tbh.
The third option seems to be adding a custom context processor to achieve the same goal, i.e. making settings values available to the templates that are interested therein. Sorry about a long question of "design" variety.
ok, so it was a wrong path after all - the reason why {{ domain }} in my template didn't work (resolved to 'localhost') was a missing line in nginx config:
location / {
proxy_pass http://unix:/run/gunicorn.sock;
proxy_set_header Host $http_host;
}
(the proxy_set_header line, to be exact)
can't claim I understand 100% what's happening here, but at least now I can move forward; the biggest question is where this {{ domain }} directive comes from - can't tell which of the several context processors copied from a tutorial put it in:
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",

Create subdomain for each user that signs up

I am developing a project in Coldfusion with CFWheels MVC Framework with URL Rewriting enabled. It involves user registration and each user should be presented as username.domain.com instead of www.domain.com/users/username. Moreover once I am on username.domain.com all child pages should work as:
username.domain.com/page1
username.domain.com/page2
username.domain.com/search?k=xyz
... etc
which I am unable to achieve.
I have updated my DNS settings of the particular domain so that *.domain.com all point to the same host. What am I still doing? I found this configuration , but I have not figured out how to implement it.
Sorry this is more of an extended comment than an answer
The code has a name of coldfusion-subdomains.cfm but it looks like something that would go into application.cfc. If you look at https://github.com/cfmaniac/CF-SubDomains , it states
CF-Subdomains is a snippet of code (best used in your OnRequest Method of Application.cfc) to detect and include files from a subdirectory on your server and let it act like a subdomain.
So from here, I would go to the cfwheels documentation so see if it does anything special with OnRequest()
I don't see anything that wraps around OnRequest(), so maybe it can be used as is
You may also want to consider url re-writing instead
http://docs.cfwheels.org/docs/url-rewriting

How to change Magento's Soap Address Location to HTTPS

I am trying to change our wsdl to use a secure URL as the end point. We are using the V2, WSI Compliant API and this is the line I am trying to change:
<soap:address location="http://mydomain.com/index.php/api/v2_soap/index/"/>
I want to change it to:
<soap:address location="https://mydomain.com/index.php/api/v2_soap/index/"/>
I really need to find out where the {{var wsdl}} is being passed in. I have tried hard coding it in one place, but the way the wsdl is being compiled (much like the config is generated), it appends the soap address (and has both the secure and unsecure in the final product). That's not really the way I wanted to do it, anyway. I'm wondering if there's a design template that's driving all of this where I could declare a new variable or reset the wsdl.url bit. I've tried changing some code (just to see if this was the origin of the url) in Mage_Api_Model_Server_V2_Adapter_Soap and Mage_Api_Model_Server_Adapter_Soap to no avail. Does anybody have any advice?
I actually figured this out and it was much easier than I expected. This is accomplished by going to System->Configuration->Web->Secure->Use Secure URLs in Admin = Yes.

apache server not redirecting correctly

I have written a module in apache which logs information when invoked lets say the url it is pointing at is localhost:12345/imp, i would like to subsequently after executing the code in this module redirect each request to different URL say for example www.cnn.com.
apr_table_add(r->headers_out, "Location","www.cnn.com" );
return HTTP_TEMPORARY_REDIRECT;
I have tried the above in my module however all it seems to do is call my module twice and it seems to be attempting to access localhost:12345/www/cnn/com. Surely there must be someone who has done similar to what i am attempting, can someone please advise?
Many thanks
The internet standard requires an absolute URI to follow a Location header, which means it must contain a scheme (e.g., http:, https:, telnet:, mailto:).
You should use :
apr_table_add(r->headers_out, "Location","http://www.cnn.com" );

making permanent changes to the path of cookies

Where can I make changes if I want to make permanent changes in cookie-path value for my website. will that be in context.xml or web.xml or will that be using newCookie.setPath() method only? The server is Tomcat 6.0. I did look online but have not found anything, to the point.
Its just that there is some problem with the session tracking and admin thinks that this requires changing path of my session cookies from /site-folder to /. Is he wrong?
It might not be something considered good programming trick, but to change the sessioncookiepath value, web-app>METAINF>context.xml file is the place. For perticulary my problem, putting following code helped: Context sessionCookiePath="" This might be due to my website structure.