I have two versions of a site, one for spanish, one for english. The spanish subdomain is set via IIS and a C Name (network admin told me, I'm not sure how or what that means), it's not a separate subdomain.
es.website.com
en.website.com
Now, when I use CGI.SERVER_NAME on my development server, everything works nicely. However, in production, when I'm on es.website.com, despite my Application.cfc settings, it thinks the origin is en.website.com, which throws off my <cfheader name="Access-Control-Allow-Origin" value="#application.site#">.
Here is how I differentiate the domains and sites to determine which content must be in spanish:
application.subdomain = ListFirst(cgi.SERVER_NAME, ".");
if (application.test) {
if (application.subdomain == "en") {
application.site = "http://en.dev.website.com/";
} else {
application.site = "http://es.dev.website.com/";
}
} else {
if (application.subdomain == "en") {
application.site = "http://en.website.com/";
} else {
application.site = "http://es.website.com/";
}
}
I cannot figure out why when on other pages, application.sites is clearly es.website.com, yet on some pages, the cgi.server_name reverts to en.website.com. Any insight?
If you are storing it in an application scoped variable then users can change the variable mid request. You don't see this on your dev server because you don't have any concurrent users.
Assume you have a request to en.website.com then 1 millisecond later a request to es.website.com both requests will share the same application scope, the second request will change the value of application.site to the ES version.
A better solution would be to use a request scoped variable for this since the value differs by request.
Another less elegant solution would be to make sure each site has a different application name, for example:
this.name = LCase(cgi.server_name) & "_website";
That would cause each domain to have its own application scope, which depending on how your web server is setup could lead to a denial of service condition (if you allow any domain to hit the application).
Related
I am not at all Ember developer, but I would like to change current route from browser console. Is it possible at all to access correctly Ember, e.g. Ember.Router.prototype.transitionTo('/feed')?
Version of the website is 3.16.9
After a lot of research, I have found out possible solutions that you can use. I was trying to achieve it on Linkedin website via Chrome Extension
function runEmbedded(path) {
const namespaces = window.Ember.Namespace.NAMESPACES;
let application;
namespaces.forEach(function (namespace) {
if (namespace instanceof window.Ember.Application) {
application = namespace;
return false;
}
});
application.__container__.lookup('router:main').transitionTo(path);
}
const payload = '/some/new-path'
script.text = `(${runEmbedded.toString()})('${payload}');`;
document.documentElement.appendChild(script);
Second solution/hack:
Another possible hack to use, when the website is not listening to pushState/replaceState actions from History API is to push state 2 times and then go back. Please remember that's only a hack.
history.pushState({}, '', msg.payload);
history.pushState({}, '', msg.payload);
history.back();
On my local windows PC I am running XAMPP and it is serving a testpage on it (e.g. http://localhost/testsite/testpage.html)
Now on the same machine I have an instance of laravel 5.2 running and I have one named route in it called testroute.
I write a phpunit test cases
public function testBasicExample1() {
$this->visit('testroute')->see('Something'); //Passes
}
public function testBasicExample2() {
$this->visit('http://www.google.com')->see('Google'); //Passes
}
public function testBasicExample3() {
$this->visit('http://localhost/testsite/testpage.html')->see('Something Else');
//Fails as it is unable to reach the desired page (Received status code [404])
}
in TestCase.php
$baseUrl = 'http://localhost:8000';
and in .env APP_URL=http://localhost:8000
Is it know that localhost sites cannot be accessed in phpunit?
Update:
I figured out even http://www.google.com is not working, it is redirecting to the laravel's welcome route. (test passed as there was text 'Google' in that page as well). Basically it was trying to assess http://localhost:8000/www.google.com and that redirects to welcome page.
I am not sure how in laravel's phpunit I can access external url.
I banged my head against a wall for a long time with this. I don't believe it is possible / functional to test external sites with the Laravel click() or visit() methods. If it is, I'm not seeing it.
Though my need was to just check all my links, perhaps this hack may be helpful to you. I went back to basic php to assert the sites returned properly.
$sites = \App\Website::pluck('website');
foreach($sites as $site) {
$file_headers = #get_headers($site);
if (strpos($file_headers[0], '404 Not Found') || $file_headers[0] == null) {
$exists = false;
echo " Failed on: ".$site." ";
}
else {
$exists = true;
}
$this->assertTrue($exists);
}
It doesn't quite get you all the way to what you want (seeing something), but for me it was good enough to be able to see the link was live and successful.
Testing is slow as it is going out to x # of sites.
HTH
Using MoovWeb for a large eCommerce client. They want to block desktop users from visiting the mobile site. So basically, if a user is using a desktop browser and tries to visit (m.site.com) they will be redirected to (site.com).
Must do this in Tritium (most likely near the top of main.ts), because by the time JS runs, we'd be loading the site twice (once in m. then once again in www.)
I'm hesitant to go the route of using Regex to check $user_agent, because if we don't match EVERY POSSIBLE mobile agent, and the user goes to m. on their unmatched phone, they will get an endless redirect (m. > www. > m. > www. > m. > ...). I know there are very detailed Regex strings for user agents, however as detailed as they are, the only way we would find out that some phone out there is no longer matched is through loss of sales, which is not an option.
Here was my original Tritium test attempt, which causes redirect for mobile users that don't use Android or iPhone:
match($host,/^m\./) {
match($user_agent) {
not(/(Android|iPhone)/) {
$newHost = $host
$newHost {
replace(/^m\./,"")
}
$redirect = "http://"+$newHost+$path
export("Location",$redirect)
}
}
}
Moovweb provides redirection both client side and server side out-of-the-box. It's recommended that you implement server-side redirection which has the least amount of roundtrips.
Here is the official documentation:
https://moovwebconfluence.atlassian.net/wiki/display/DD/Mobile+Redirection#MobileRedirection-Server-SideRedirection
Best,
Juan C.
match($host,/m./) {
$newHost = $host
$newHost {
replace(/m./,"www.")
}
$redirect = "http://"+$newHost+$path
export("Location",$redirect)
}
Try this. Hope this will work you as this worked for me.
We are trying to create a cookie in the PeopleSoft Peoplecode by using the %Response object.
However, the code we tried is failing.
&YourCookie = %Response.AddCookie("YourCookieName", "LR");
Another snippet we tried to create the cookie
Local object &Response = %Response;
Local object &YourCookie;
&YourCookie = &Response.CreateCookie("YourCookieName");
&YourCookie.Domain = %Request.AuthTokenDomain;
&YourCookie.MaxAge = -1; /* Makes this a session cookie (default) */
&YourCookie.Path = "/";
&YourCookie.Secure = True; /* Set to true if using https (will still work with http) */
&YourCookie.Value = "Set the cookie value here. Encrypt sensitive information.";
The document reference points to IScript functions called CreateCookie methods etc.
http://docs.oracle.com/cd/E15645_01/pt850pbr0/eng/psbooks/tpcr/chapter.htm?File=tpcr/htm/tpcr21.htm
However, these don't work in Peoplecode. We don't have the knowledge to create IScript or use it. Any insight with the People code API for cookies or IScript is much appreciated.
I just tested on PeopleTools 8.54.11 and was able to create a cookie using the snippet you provided above.
I did find I had an issue if I set
&YourCookie.Secure = True;
in an environment where I was using HTTP.
If you set Secure to False the cookie will be available in both HTTP and HTTPS
if you set Secure to True the cookie is only available in HTTPS
PeopleTools 8.54 Documentation showing the CreateCookie method
I have been trying to do this (same code snippet) from within signon peoplecode, tools release is 8.54.09. I can execute the first two lines of code, but as soon as the line of code executing the CreateCookie() method executes, I get tossed out / end up on the signon error page.
This seems to support the previous answer saying that the API has removed the method, but the answer before that says it has been successful on tools 8.54.11 -- does that mean they removed it, then put it back, and I happen to be stuck with a release where it was removed? :-/
For my Flash Builder 4.6 Project I have a http service defined which looks at a url from our website.
What I'd like to be able to do though is to change the web service url on the fly within the app. i.e. using the existing url as default but having an admin/settings screen to change where the web service points (either stored in our sqlite database or in local memory).
This would be so that we could allow our customers to host their own version of the website/database but still be able to use/download the app through the app stores.
Has anyone had any experience with doing this?
EDIT: Adding some more details after the comments below.
When I created the HTTP Service through the FlashBuilder wizard it creates two web service classes a super class and a sub class which inherits from the super class. All of the code that the wizard populates goes into the super class.
I can assume that the code I need to put in would be in the sub class. But I do not know which function I'd put it in or how.
Below is a sample of the Super's constructor:
// initialize service control
_serviceControl = new mx.rpc.http.HTTPMultiService("websitehere");
var operations:Array = new Array();
var operation:mx.rpc.http.Operation;
var argsArray:Array;
operation = new mx.rpc.http.Operation(null, "loginRequest");
operation.url = "login.php";
operation.method = "GET";
argsArray = new Array("un","pw");
operation.argumentNames = argsArray;
operation.serializationFilter = serializer0;
operation.properties = new Object();
operation.properties["xPath"] = "/";
operation.contentType = "application/x-www-form-urlencoded";
operation.resultType = valueObjects.Data;
operations.push(operation);
_serviceControl.operationList = operations;
I'm not sure what property of the _serviceControl variable I would need to alter.
Also when I search for my website in my code it brings back a .fml file inside a .model directory which seems to get auto refreshed if I change the service url through the wizard. Would this not cause an issue?
I then have the challenge of accessing the user defined url. Within the app we use an sqlite database to store data but I think it would probably be better to use a 'SharedObject' which we also use to know what account they are logged into. How reliable is this? I assume I would be able to access this via the Service?
Though the awkward thing is that we were planning to have this configurable on a settings screen that would have been accessed after logging in. But to log in it would already need to know which server to point to.
if im reading your question correctly then your main ambition is to dynamically change the url for the services based on a user defined variable.
This is very easy to accomplish and even easier to accomplish if you are using parsley / spicelib.
a few points
dont change the code in the super file, this will get overwritten whenever the service gets refreshed. change everything in its generated sub-Class.
Shared Objects are very good for small quantities of data but should never be used for massive datasets i.e storing a big arraycollection.
Anyway here is how i achieve this.
In the SubClass you can change the constructor function.
Here is how i change my urls based on a config variable but you can just as easily use a SharedObject instead.
public function SubClassConstructor(){
if(CONFIG::DOMAIN_IDENT == "development" || CONFIG::DOMAIN_IDENT == "dev" || CONFIG::DOMAIN_IDENT == "d"){
_serviceControl.endpoint = "http://yoururl1";
}
else if(CONFIG::DOMAIN_IDENT == "production" || CONFIG::DOMAIN_IDENT == "prod" || CONFIG::DOMAIN_IDENT == "p"){
_serviceControl.endpoint = "http://yoururl2";
}
}
Of course this isn't exactly what your looking for but its a working solution, of course you can use Bindings to a Global ApplicationModel or direct reference to the SharedObject i guess you already know how to use the SharedObject.
Ask if you need any further help or guidance.
As cghrmauritius' solution didn't quite work for me, I am posting up the final solution that did work in my situation.
public function subConstructor()
{
super();
_serviceControl.baseURL = "http://url1";
}
Obviously for my final solution I need to implement the shareobject as well but overriding the url was my main priority.