I need to generate an absolute URL that will use the secure HTTP protocol since it's a payment page template used by a third party payment gateway solution that requires every single element on the page to point to or to come from an HTTPS link. Now, I can't for the life of me find how to use the Twig url() function to generate a secure URL. Anything you add to the function in an array is considered a GET parameter that will be appended at the end of the URL in a ?x=y manner.
How can I generate an HTTPS URL using the Twig url() function???
Thanks in advance.
The URLs generated by twig are determined by your routing configuration. You need to set the route to require https.
requirements:
_scheme: https
You can read more about it here:
http://symfony.com/doc/2.0/cookbook/routing/scheme.html
Related
I have a model called Campaign and every Campaign has one attachment.
I use S3 ActiveStorage storage and I need a PERMANENT URL for my Campaign images.
I currently generate URLs like:
campaign.image.service_url
But this link expires in 5 minutes. I need non-expire links. (Config settings only let me get a URL that expires in 1 week, it does not solve my problem again)
How can I get URLs of my images?
EDIT
Solution:
I use CloudFront as CDN. This is the solution I found:
https://domainName+/campaign.image.key
this gives a link to an image file that does not expire.
Check the docs https://api.rubyonrails.org/classes/ActiveStorage/Variant.html#method-i-service_url
You are not supposed to expose service_url directly:
Returns the URL of the variant on the service. This URL is intended to be short-lived for security and not used directly with users. Instead, the service_url should only be exposed as a redirect from a stable, possibly authenticated URL. Hiding the service_url behind a redirect also gives you the power to change services without updating all URLs. And it allows permanent URLs that redirect to the service_url to be cached in the view.
Use url_for(variant) (or the implied form, like +link_to variant+ or +redirect_to variant+) to get the stable URL for a variant that points to the ActiveStorage::RepresentationsController, which in turn will use this service_call method for its redirection.
So use url_for(campaign.image) (or url_for(campaign.image.some_variant)) instead.
The URL that is not expire is simple and without any params:
http[s]://[bucket-name.s3].amazonaws.com/pathtofile/file.extention
You can get this URL from the AWS SDK by using S3::Objects :public_url method
With active storage you can do
url ="#{campaign.image.service.bucket.url}/#{campaign.image.blob.key}"
Then you would need to configure the public access settings on the S3 bucket.
Is there a inbuilt library in ExtJS v6 or v7 that could help in parsing rest style url pathname. For example a pathname "/abc/123/def/456/geh" should return `{ abc_id: 123, id: 456 }
No, because REST-style URLs are for web services, not single-page apps (SPA). A SPA is intended to be represented by a single URL. If you try to use REST-style URLs, the browser will reload the page, restarting the app.
Navigation within that URL can be done via routes (done in the anchor portion of the URL, after the #). For more information on using routes, check the documentation.
ive been doing a stephen grider course and he creates a google oauth client id with authorised js orgins as http://localhost:5000 and authorised redirect URI as http://localhost:5000/* and google accepts it. But when i try the same it throws me an error for redirect URI as Invalid redirect: Cannot contain a wildcard (*). And im not sure without this , further it will cause problems.Any way to solve this. Ive typed http://localhost:5000/ as a temp solution. Kindly suggest.
What ever course you are following must be very old I have been developing with Google for five years a wildcard redirect uri has not been allowed in that time.
Authorized redirect URIs
For use with requests from a web server. This is the path in your application that users are redirected to after they have authenticated with Google. The path will be appended with the authorization code for access. Must have a protocol. Cannot contain URL fragments or relative paths. Cannot be a public IP address.
Redirect uri must be a path to the file you wish to use to handle your authorization.
The redirect URL you configure to the API console must be an exact string match to the redirect URL you use in your app. So for example, http://localhost:5000 does not match http://localhost:5000/ or https:5000//localhost. Thus a wildcard will never work.
Furthermore, it's very unusual for a redirect URL to not have a path component. So something like http://localhost:5000/myoauth is more conventional. That's not to say that an empty path is impossible, simply that it's so unusual that it's more probable you have misunderstood OAuth somewhere.
However, note that you can configure several redirect URLs, so http://local:5000 and https://localhost:5000 and https://myliveservice.com/redirect
According to this article, https://support.google.com/adwords/answer/6076199
When you define a final URL as your landing page, you can use URL options to manage your tracking and redirect information.
So, my website is example.com and the 3rd party service I use is called 3rdpartytracker.com
Let's say that I own the 3rdpartytracker website too.
http://www.3rdpartytracker.com/rd?keyword={_mykwid}&ad={creative}&url={lpurl}
Do I have to set a redirection script into 3rdpartytracker.com to send me back to the example.com ?
Or it will take me automatically back ?
I mean how does this work in a more technical approach ?
Thank you
If you own the both 3rdpartytracker.com and example.com then, yes, you will have to set a redirection script on 3rdpartytracker.com to extract the url parameter from the request to 3rdpartytracker.com and redirect to the url parameter value (in this case example.com).
I actually think that this blogpost provides a clearer explanation of Upgraded URLs in AdWords.
And if you can explain this to somebody else without mistakenly saying Final Destination then you're a better person than me!
Some PHP MVC has the index.php for the front controller. Now, my question is, putting a slash / and action after the document index.php makes it a valid URL? Also, does /action?var=val means that action is a file, not a directory? I'm really confused if I'll follow such URL format.
Thanks in advance!
It is a valid URL. In fact, with URL rewriting, pretty much anything can be a valid URL.
People often use the index.php/controller/action fallback if they can't rewrite the URL. It still works and they can access the URL used within PHP to still process it.