Separate Desktop and Mobile sites - How do i plan the backend?How to print a number with commas as thousands separators in JavaScriptPHP redirect to mobile version if user browses to subdomainhtaccess create the appearance of a subdomin but use a MVC controller instead of a folderHow I can avoid requesting Basic Authentication when HTTP method is OPTIONS on Apache .htaccess?How to implement OAuth 2.0 like token based authentication for rest API which is accessed from mobile and javascript web applicationsHow to manage session for a user logged in from mobile app in PHP?How to get domain name with PHPWhy is my subdomain redirecting to www.m.example.comHow to implement different sub domain for different web roles hosted in a single cloud serviceNeed some assistance with redirects in .htaccess

Took a trip to a parallel universe, need help deciphering

Python: return float 1.0 as int 1 but float 1.5 as float 1.5

How could indestructible materials be used in power generation?

Brothers & sisters

Why do I get two different answers for this counting problem?

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

Can a virus destroy the BIOS of a modern computer?

Were any external disk drives stacked vertically?

Why does Kotter return in Welcome Back Kotter

Can I use a neutral wire from another outlet to repair a broken neutral?

Combinations of multiple lists

1960's book about a plague that kills all white people

Is it unprofessional to ask if a job posting on GlassDoor is real?

Did Shadowfax go to Valinor?

What exploit are these user agents trying to use?

intersection of two sorted vectors in C++

Alternative to sending password over mail?

Why is Collection not simply treated as Collection<?>

Why can't we play rap on piano?

90's TV series where a boy goes to another dimension through portal near power lines

What reasons are there for a Capitalist to oppose a 100% inheritance tax?

SSH "lag" in LAN on some machines, mixed distros

Is the Joker left-handed?

Is it possible to create light that imparts a greater proportion of its energy as momentum rather than heat?



Separate Desktop and Mobile sites - How do i plan the backend?


How to print a number with commas as thousands separators in JavaScriptPHP redirect to mobile version if user browses to subdomainhtaccess create the appearance of a subdomin but use a MVC controller instead of a folderHow I can avoid requesting Basic Authentication when HTTP method is OPTIONS on Apache .htaccess?How to implement OAuth 2.0 like token based authentication for rest API which is accessed from mobile and javascript web applicationsHow to manage session for a user logged in from mobile app in PHP?How to get domain name with PHPWhy is my subdomain redirecting to www.m.example.comHow to implement different sub domain for different web roles hosted in a single cloud serviceNeed some assistance with redirects in .htaccess






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Not sure under which category my question falls. I'm in great confusion and really need some expert suggestions.



I have PHP site for E-commerce (Opencart) running on the domain- www.example.com and developed a PWA mobile website which is ready to be launched, at this point I have fallen into so many confusion.



  • I want to host a mobile site with subdomain m.example.com. The backend (REST API) is same for desktop and the mobile site which is hosted in example.com

  • when I make API calls from m.example.com to example.com preflight OPTION request is sent for each and every request which almost takes 200ms to 300ms.

  • There is an option to avoid OPTION requests by making the simple request, but not possible with my case as I have Token based authentication and need to token in every API call


  • To avoid OPTION requests, the option is to host the same REST API in m.example.com as well (just checked mobile.twitter.com API request goes to mobile.twitter.com), and both m.exampole.com and example.com sharing common Database.


  • This has another problem, any change in the API needs the update in both sites.

My questions are



  • What is the optimal way of handling this situation?


  • if I'm going with m.example.com - the redirection can be done at front-end level or via a .htaccess rule, which option is ideal?


  • Is it a good idea to host REST API in m.example.com as well?










share|improve this question



















  • 2





    Please, for the love of any future developers looking at this codebase, do not create 2 versions of the site. Use some responsive css and then you only need to maintain one version of the site. If however; you insist on creating 2 versions of the site; there is no way to prevent the OPTIONS request because that's the browser reaching out the get the Access-Control-Allowed-Origin headers to see if it's allowed to interact with that server. Update your Access-Control-Allowed-Origin to contain all the domains that will access that service. welcome to the world of CORS, prepare to cry.

    – Adam H
    Mar 21 at 22:04






  • 1





    Just one instance of the service with the correct headers set will address your problems, all API calls can go to www.example.com even from m.example.com.

    – Adam H
    Mar 21 at 22:05











  • I have enabled CORS already. I have checked some of mobile sites for example mobile.twitter.com , m.snapdal.com, m.licious.in etc , they all make API to same subdomain instead of main domain . Just curios to know how do they do it? By hosting API is subdomain as well ??? @AdamH

    – monda
    Mar 21 at 22:11












  • It's all in the Access-Control-Allow-Origin Header that your web service returns. If you are using credentials then you can't use * for the header, instead set it to Request.Origin or whatever the equivalent is in PhP

    – Adam H
    Mar 21 at 22:14


















0















Not sure under which category my question falls. I'm in great confusion and really need some expert suggestions.



I have PHP site for E-commerce (Opencart) running on the domain- www.example.com and developed a PWA mobile website which is ready to be launched, at this point I have fallen into so many confusion.



  • I want to host a mobile site with subdomain m.example.com. The backend (REST API) is same for desktop and the mobile site which is hosted in example.com

  • when I make API calls from m.example.com to example.com preflight OPTION request is sent for each and every request which almost takes 200ms to 300ms.

  • There is an option to avoid OPTION requests by making the simple request, but not possible with my case as I have Token based authentication and need to token in every API call


  • To avoid OPTION requests, the option is to host the same REST API in m.example.com as well (just checked mobile.twitter.com API request goes to mobile.twitter.com), and both m.exampole.com and example.com sharing common Database.


  • This has another problem, any change in the API needs the update in both sites.

My questions are



  • What is the optimal way of handling this situation?


  • if I'm going with m.example.com - the redirection can be done at front-end level or via a .htaccess rule, which option is ideal?


  • Is it a good idea to host REST API in m.example.com as well?










share|improve this question



















  • 2





    Please, for the love of any future developers looking at this codebase, do not create 2 versions of the site. Use some responsive css and then you only need to maintain one version of the site. If however; you insist on creating 2 versions of the site; there is no way to prevent the OPTIONS request because that's the browser reaching out the get the Access-Control-Allowed-Origin headers to see if it's allowed to interact with that server. Update your Access-Control-Allowed-Origin to contain all the domains that will access that service. welcome to the world of CORS, prepare to cry.

    – Adam H
    Mar 21 at 22:04






  • 1





    Just one instance of the service with the correct headers set will address your problems, all API calls can go to www.example.com even from m.example.com.

    – Adam H
    Mar 21 at 22:05











  • I have enabled CORS already. I have checked some of mobile sites for example mobile.twitter.com , m.snapdal.com, m.licious.in etc , they all make API to same subdomain instead of main domain . Just curios to know how do they do it? By hosting API is subdomain as well ??? @AdamH

    – monda
    Mar 21 at 22:11












  • It's all in the Access-Control-Allow-Origin Header that your web service returns. If you are using credentials then you can't use * for the header, instead set it to Request.Origin or whatever the equivalent is in PhP

    – Adam H
    Mar 21 at 22:14














0












0








0








Not sure under which category my question falls. I'm in great confusion and really need some expert suggestions.



I have PHP site for E-commerce (Opencart) running on the domain- www.example.com and developed a PWA mobile website which is ready to be launched, at this point I have fallen into so many confusion.



  • I want to host a mobile site with subdomain m.example.com. The backend (REST API) is same for desktop and the mobile site which is hosted in example.com

  • when I make API calls from m.example.com to example.com preflight OPTION request is sent for each and every request which almost takes 200ms to 300ms.

  • There is an option to avoid OPTION requests by making the simple request, but not possible with my case as I have Token based authentication and need to token in every API call


  • To avoid OPTION requests, the option is to host the same REST API in m.example.com as well (just checked mobile.twitter.com API request goes to mobile.twitter.com), and both m.exampole.com and example.com sharing common Database.


  • This has another problem, any change in the API needs the update in both sites.

My questions are



  • What is the optimal way of handling this situation?


  • if I'm going with m.example.com - the redirection can be done at front-end level or via a .htaccess rule, which option is ideal?


  • Is it a good idea to host REST API in m.example.com as well?










share|improve this question
















Not sure under which category my question falls. I'm in great confusion and really need some expert suggestions.



I have PHP site for E-commerce (Opencart) running on the domain- www.example.com and developed a PWA mobile website which is ready to be launched, at this point I have fallen into so many confusion.



  • I want to host a mobile site with subdomain m.example.com. The backend (REST API) is same for desktop and the mobile site which is hosted in example.com

  • when I make API calls from m.example.com to example.com preflight OPTION request is sent for each and every request which almost takes 200ms to 300ms.

  • There is an option to avoid OPTION requests by making the simple request, but not possible with my case as I have Token based authentication and need to token in every API call


  • To avoid OPTION requests, the option is to host the same REST API in m.example.com as well (just checked mobile.twitter.com API request goes to mobile.twitter.com), and both m.exampole.com and example.com sharing common Database.


  • This has another problem, any change in the API needs the update in both sites.

My questions are



  • What is the optimal way of handling this situation?


  • if I'm going with m.example.com - the redirection can be done at front-end level or via a .htaccess rule, which option is ideal?


  • Is it a good idea to host REST API in m.example.com as well?







javascript php .htaccess subdomain e-commerce






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 22:14







monda

















asked Mar 21 at 21:58









mondamonda

1,60394273




1,60394273







  • 2





    Please, for the love of any future developers looking at this codebase, do not create 2 versions of the site. Use some responsive css and then you only need to maintain one version of the site. If however; you insist on creating 2 versions of the site; there is no way to prevent the OPTIONS request because that's the browser reaching out the get the Access-Control-Allowed-Origin headers to see if it's allowed to interact with that server. Update your Access-Control-Allowed-Origin to contain all the domains that will access that service. welcome to the world of CORS, prepare to cry.

    – Adam H
    Mar 21 at 22:04






  • 1





    Just one instance of the service with the correct headers set will address your problems, all API calls can go to www.example.com even from m.example.com.

    – Adam H
    Mar 21 at 22:05











  • I have enabled CORS already. I have checked some of mobile sites for example mobile.twitter.com , m.snapdal.com, m.licious.in etc , they all make API to same subdomain instead of main domain . Just curios to know how do they do it? By hosting API is subdomain as well ??? @AdamH

    – monda
    Mar 21 at 22:11












  • It's all in the Access-Control-Allow-Origin Header that your web service returns. If you are using credentials then you can't use * for the header, instead set it to Request.Origin or whatever the equivalent is in PhP

    – Adam H
    Mar 21 at 22:14













  • 2





    Please, for the love of any future developers looking at this codebase, do not create 2 versions of the site. Use some responsive css and then you only need to maintain one version of the site. If however; you insist on creating 2 versions of the site; there is no way to prevent the OPTIONS request because that's the browser reaching out the get the Access-Control-Allowed-Origin headers to see if it's allowed to interact with that server. Update your Access-Control-Allowed-Origin to contain all the domains that will access that service. welcome to the world of CORS, prepare to cry.

    – Adam H
    Mar 21 at 22:04






  • 1





    Just one instance of the service with the correct headers set will address your problems, all API calls can go to www.example.com even from m.example.com.

    – Adam H
    Mar 21 at 22:05











  • I have enabled CORS already. I have checked some of mobile sites for example mobile.twitter.com , m.snapdal.com, m.licious.in etc , they all make API to same subdomain instead of main domain . Just curios to know how do they do it? By hosting API is subdomain as well ??? @AdamH

    – monda
    Mar 21 at 22:11












  • It's all in the Access-Control-Allow-Origin Header that your web service returns. If you are using credentials then you can't use * for the header, instead set it to Request.Origin or whatever the equivalent is in PhP

    – Adam H
    Mar 21 at 22:14








2




2





Please, for the love of any future developers looking at this codebase, do not create 2 versions of the site. Use some responsive css and then you only need to maintain one version of the site. If however; you insist on creating 2 versions of the site; there is no way to prevent the OPTIONS request because that's the browser reaching out the get the Access-Control-Allowed-Origin headers to see if it's allowed to interact with that server. Update your Access-Control-Allowed-Origin to contain all the domains that will access that service. welcome to the world of CORS, prepare to cry.

– Adam H
Mar 21 at 22:04





Please, for the love of any future developers looking at this codebase, do not create 2 versions of the site. Use some responsive css and then you only need to maintain one version of the site. If however; you insist on creating 2 versions of the site; there is no way to prevent the OPTIONS request because that's the browser reaching out the get the Access-Control-Allowed-Origin headers to see if it's allowed to interact with that server. Update your Access-Control-Allowed-Origin to contain all the domains that will access that service. welcome to the world of CORS, prepare to cry.

– Adam H
Mar 21 at 22:04




1




1





Just one instance of the service with the correct headers set will address your problems, all API calls can go to www.example.com even from m.example.com.

– Adam H
Mar 21 at 22:05





Just one instance of the service with the correct headers set will address your problems, all API calls can go to www.example.com even from m.example.com.

– Adam H
Mar 21 at 22:05













I have enabled CORS already. I have checked some of mobile sites for example mobile.twitter.com , m.snapdal.com, m.licious.in etc , they all make API to same subdomain instead of main domain . Just curios to know how do they do it? By hosting API is subdomain as well ??? @AdamH

– monda
Mar 21 at 22:11






I have enabled CORS already. I have checked some of mobile sites for example mobile.twitter.com , m.snapdal.com, m.licious.in etc , they all make API to same subdomain instead of main domain . Just curios to know how do they do it? By hosting API is subdomain as well ??? @AdamH

– monda
Mar 21 at 22:11














It's all in the Access-Control-Allow-Origin Header that your web service returns. If you are using credentials then you can't use * for the header, instead set it to Request.Origin or whatever the equivalent is in PhP

– Adam H
Mar 21 at 22:14






It's all in the Access-Control-Allow-Origin Header that your web service returns. If you are using credentials then you can't use * for the header, instead set it to Request.Origin or whatever the equivalent is in PhP

– Adam H
Mar 21 at 22:14













0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55289889%2fseparate-desktop-and-mobile-sites-how-do-i-plan-the-backend%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55289889%2fseparate-desktop-and-mobile-sites-how-do-i-plan-the-backend%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현