Ember.js, Rails and Wildcard Subdomains - ruby

How can I use ember.js routing with rails wildcard subdomains?
Say, a user signs up on the site, they get a subdomain. Joe and Josh both sign up, they each get a subdomain.
joe.mysite.com
josh.mysite.com
Rails routes all my api calls (routes.rb) while ember routes everything else. What would the best way of doing this? Using rails or ember to route it? Is it even possible to use ember to route subdomains?

The best way would be programmatically checking with location.host or location.hostname.
But ember usually works it's magic by faking URLs and not reloading the page... I don't know of any way to switch subdomains without reloading the page.
I'd redirect the subdomain to a URL in your main app and let Ember handle the routing from there.

Related

ngnix - rewrite url based on path

I have my next.js app working on http://testdomain.amazonaws.com:443/abc.
Using ngnix configuration, I would like to have https://anotherdomain.com/abc to render my app at http://testdomain.amazonaws.com:443/abc without changing the url in the address bar and also it should take the routes from the next.js app keeping the https://anotherdomain.com.
That is, if user clicks on other links and navigates to other routes like
http://testdomain.amazonaws.com:443/abc/pqr/1 it should become https://anotherdomain.com/abc/pqr/1 in the url.
Can anyone help me understand if we can write a rewrite rule to achieve this in ngnix?

Laravel SPA (laravel + vuejs + sanctum) deployed in subdomain returns wrong api

I have this problem since several days.
I'm developing a Vuejs/laravel app, using Sanctum as an authenticator. where laravel mainly have the api gestion role, and I've started to deploying it. On Local, everything looks fine, api and auth are working.
On deploy, since my app is binded to be in a subdomain (laravelapp.maindomain with folder path of domain/laravelapp), when i try to access any page (vue-router) instead of domain/laravelapp/login i get domain/login, even if the page itself is looking fine.
If i try to reload the redirected page (domain/page) i have a 404. Also, since every API is pointing to domain/api/link instead of domain/laravelapp/api/link, everything is broken starting with auth.
I've tried modifying .env file, RouteServiceProvider, .htaccess(but i have no knowledge about that).
I also tried to set the subdomain Document Root to domain/laravelapp (it's the first thing i've done), but not only it dosn't work, if I try to print on screen subdomain's root, it returns domain. It's becoming a real issue right now, thank you for any help.
EDIT: I've discovered something. in the main domain there is a Joomla application. The api route contains the Joomla redirect (like, there is a plugin oh the site that changes language automatically, appending /en /it /de given the chosen language). So, in my case, the api is domain/index.php/en/subdomain. I tried again being more specific with document root, with no results, and playing around with .htaccess, but with no success.

How to avoid overwriting routes in Laravel?

Sorry in advance, I know it has been asked before but I did not figure out the solution.
I am new to Laravel, still learning and stuck with this issue:
My objective is to add pages in admin and show these pages in frontend.
For the Front part of the website I have this route:
Route::get('/{page}', 'PagesController#show');
so the when you access /about, /contact, /another-page I use the same view
For the Admin part of the website I have this route:
Route::get('/admin', 'AdminController#show');
My problem is that the first route overwrites the second route and I don't know how to avoid this.
I have tried with namespaces and grouping routes, but I get the same outcome.
Thank you
To make it simple this is happening because you have the route with the parameter before the admin route so is going to send the "admin as a parameter of page"
The Simple fix is just put admin route before your "/{page} so it will find admin route first,Something Like this:
Route::get('/admin', 'AdminController#show');
Route::get('/{page}', 'PagesController#show');
But I do not recommend building your routes this way and have specifics pages setup if possible, This way of building routes will mess around with the 404 route not found aswell.

Angular UI-Router (1.x) Change Host Url

I have a requirement from a client to change the web site Url to a subdomain when they enter the checkout section of the site we are developing for them. For example from www.mysite.com to checkout.mysite.com. We are using UI-Router in HTML5 mode and would like to have the router change the Url to the subdomain instead of going to www.mysite.com/checkout. Does anyone know a way that this can be accomplished? I've also tried using pushState but without success. All of the subdomain suggestions I've tried have not worked. Honestly even if I just put a "fake" url that would work fine too. Changing the Url is more of a visual thing instead of actually redirecting to a subdomain.
After much review I found that this cannot be done because it is a security issue; even switching to a subdomain (which is what I was trying to do) is not allowed.

Cake PHP redirection

CakePHP redirection of url like *.php
My site is integrated with more than 20 other sites.
They have a url to access my site
Now i rewrite my code in CakePHP .
So i want to redirect the old urls to the corresponding cakePHP page
You may use the routes configuration to add some paths that resolve your current urls sending them to the appropriate action:
http://book.cakephp.org/2.0/en/development/routing.html#routes-configuration
However, I think you should manage that situation directly in your web server whatever it be (apache, nginx, etc).

Resources