News for hackers. Stuff that matters.
Re:You don't need that CORS request by igammarays on Monday January 03, 2022 @09:40AM (#29781187)
You don't even need an SPA. Having the backend + frontend share the same state makes development so much faster and easier it's shockingly refreshing. When building a SaaS project last year I decided to just ditch React/Angular/Vue and did everything server-side like it was 2005. I was extremely pleased at the result -- everything feels snappy, secure, and native for the browser. I was shocked at how much time and headache I saved: not having to design/deploy an API and all the trimmings (ACLs, CORS, JWTs etc.), not having to spend X hours a day wrestling with Webpack/hot reloading/npm/tree-shaking/state management, having direct access to backend secrets/state/APIs and just spitting out HTML, it's just so....lovely. It simplifies performance tuning as well, the only thing I need to optimize is the server, which is easy to do because I have 100% control and visibility, compared to debugging/optimizing JavaScript for a million different clients.
Re:You don't need that CORS request by southerntofu on Monday January 03, 2022 @09:44AM (#29781241)
And as a bonus, your site works perfectly in degraded environments (poor network conditions, no JS runtime). It's really the best way to do things: SPAs are great for applications, but for 99% of websites server-side rendering only has advantages.
Re:You don't need that CORS request by fivea on Monday January 03, 2022 @11:14AM (#29782266)
> And as a bonus, your site works perfectly in degraded environments (poor network conditions, no JS runtime).

What? No. Not at all. If you're behind a subpar network, your dynamic HTML web app does not load/refresh/update at all, and your users start to get frustrated because your crappy webpage is broken and fails to even do the most basic things.

This is not the case with SPAs, and some of the most pressing problems they solve: perceived performance, resilience to faulty network connections, and overall improved UX.

Let's put it this way: with SPAs you can design your app to work even without a working network connection. That's how resilient SPAs are to networking issues. How do you pull that off with dynamic HTML?

> but for 99% of websites server-side rendering only has advantages.

No, not really. Unless you cherry-pick what goes into the 99%, even basic CRUD, form-driven pages the dynamic HTML way suffers from a multitude of drawbacks that are no longer issues in SPAs, both technical and organizational.

Re:You don't need that CORS request by midrus on Monday January 03, 2022 @11:36AM (#29782555)
> This is not the case with SPAs,

LOL. I'm yet to see a single SPA which can tolerate a bad network. You certainly have better tools to do it, but it still takes a ton of effort and nobody does it. So it ends up failing in worse ways because now the application just stalls and you don't even get the standard browser errors/timeouts.

Unless SPAs are built as "offline first" I haven't seen a single one which works better than a traditional MVC app in such conditions.

Re:You don't need that CORS request by datavirtue on Monday January 03, 2022 @03:58PM (#29786774)
Yeah, have fun building an "offline first" app if your scope is anywhere in excess of Postman.
Re:You don't need that CORS request by bwilliams on Monday January 03, 2022 @01:29PM (#29784311)
The advantages you listed are potential advantages but the reality is often different. Those features don't come for free, and given the number of SPA's out in the wild it's rare that functionality like offline mode or gracefully degrading when running into faulty network connections are actually built, let alone maintained.

Most of the time SPA's degrade very poorly and instead of breaking they often appear as if they're somewhat working but the site is actually in a broken state and will need a complete refresh to become usable again.

Re:You don't need that CORS request by scns on Monday January 03, 2022 @11:29AM (#29782473)
> If you're behind a subpar network

There is a (high) probability users will close the tab after waiting for over a minute for MBs of JS to download and parse.

Re:You don't need that CORS request by fivea on Monday January 03, 2022 @12:18PM (#29783225)
> There is a (high) probability users will close the tab after waiting for over a minute for MBs of JS to download and parse.

I'm not sure what leads you to believe that a SPA requires "MBs of JS" to work. I've worked on a popular SPA deployed to multiple regions and with tons of localization data, and the total payload stayed well below 1MB. Plenty of dynamic HTML content, specially images, require far more than that.

In fact, this very discussion on HN, a very spartan dynamic HTML page, currently requires over 250kB as it dumps all the threads regardless of whether you read them or not. As a contrast, Reddit's frontpage takes 750kB.

Re:You don't need that CORS request by igammarays on Monday January 03, 2022 @01:19PM (#29784152)
Wow, the fact that you compare Reddit to HN, and you consider the Reddit SPA to be "better" means you have a fundamentally different notion of better. For me, Old Reddit and Hacker News load fast, feel snappy and native, and work better in every way, while the new Reddit SPA is sluggish, full of random network errors and bugs that I encounter regularly just clicking around, and takes up a ton of memory/CPU just to browse a discussion site.

And Reddit's frontpage size is 1.3 MB according to one check I did which checks the size of all network calls after loading, etc. and that's WITHOUT all the lazy-loaded content below the fold.

Re:You don't need that CORS request by justsomehnguy on Tuesday January 04, 2022 @03:22AM (#29792609)
> And Reddit's frontpage size is 1.3 MB

Ugh, the two chat scripts are 944KB + 1.30 *MB* alone [0]

Full page load (without touching anything at all) is 12.87MB (6.58 on wire) with 273 requests.

[0] https://imgur.com/a/bHf9CQb

Re:You don't need that CORS request by acdha on Tuesday January 04, 2022 @08:37AM (#29794524)
> I'm not sure what leads you to believe that a SPA requires "MBs of JS" to work.

> In fact, this very discussion on HN, a very spartan dynamic HTML page, currently requires over 250kB as it dumps all the threads regardless of whether you read them or not. As a contrast, Reddit's frontpage takes 750kB.

You can use tools like your browser’s developer tools or webpage test to accurately measure this. It seems like that would be a useful skill to develop for accurately reasoning about SPAs and understanding why your beliefs don’t match real users’ experiences.

For example, Reddit.com is actually 10MB of transfer, not 750KB, and it takes 5 seconds to process 6.7MB of JavaScript (47 requests to transfer 1.8MB of compressed JavaScript) which delays the start of rendering until 2 seconds in and requires almost 10 seconds to render the top of the page.

https://webpagetest.org/result/220104_AiDcHT_cf05f20e55718cf...

In contrast, the HN page requires a TOTAL of 62KB to render in less than a second:

https://webpagetest.org/result/220104_AiDcAH_1c302fd66a183aa...

That’s an enormous difference which is extremely noticeable if you don’t have a fast computer and network connection, and that’s before you get to the serious bugs Reddit has because their SPA doesn’t handle errors or session timeouts well (I see this on a near-daily basis).

I have a recent iPhone and the new Reddit SPA lags notably behind the old version, which renders twice as fast and is more reliable because it uses a tenth of the code:

https://webpagetest.org/result/220104_BiDcDZ_9bdbf4482d84584...

Re:You don't need that CORS request by southerntofu on Tuesday January 04, 2022 @07:05AM (#29793917)
> Plenty of dynamic HTML content, specially images, require far more than that. (...) this very discussion on HN, a very spartan dynamic HTML page, currently requires over 250kB

There's the difference: HTML-first approach will be able to draw everything using very little resources by the time i've loaded a few hundred kilobytes. With JS bundles i first have to wait for the scripts to load, then the dance of unreliable network-roundtrips starts and can fail in mysterious ways unknown the the browser UI.

Images will not prevent the browser from drawing the window, and they can be lazy-loaded if you consider that's better UX (of course the browser can decide to override that setting to respect user preferences). Time to full render is orders of magnitude better on simple HTML/CSS (what browsers were designed to render) than with a crap bundle that's going to trigger network connections and DOM changes (so full page redraws) in mysterious ways.

Also, i love when my refresh and back button in the browser UI do what they're supposed to do. I'm not saying it's impossible with an SPA, that's just something most SPAs i stumble upon are completely incapable to respect.

I encourage you to run the experiment. Take out an old Pentium 4 with 2G RAM, setup Firefox and in the developer bar (f12) turn on network's throttling. It will not be a realistic simulation as you would need packet loss (which other tools can simulate) but it will certainly help you measure performance and make informed decisions.

Re:You don't need that CORS request by cerved on Monday January 03, 2022 @11:35AM (#29782547)
in an SPA, that's cached, so not the second time
Re:You don't need that CORS request by acdha on Tuesday January 04, 2022 @09:03AM (#29794818)
Have you measured this carefully? All of yours users will notice it on the first visit, so you need to think about that first impression but it’s also rarely the case that people load your page so frequently that everything stays in the cache forever. Mobile devices have small caches which purge more frequently than most developers think and that’s also true of CDN nodes, and continuous deployment acts as a ceiling for long-term caching.

When I’ve measured this for real users on moderately busy sites (6 figure daily users, not Google-scale) the reported first page load times tracked the cold cache times for most users (70+%) even for people who’d visited before. If they were geographically clustered (news story, etc.) the cache hits on CDN nodes would be high but you couldn’t count on that.

Re:You don't need that CORS request by Ducki on Monday January 03, 2022 @11:42AM (#29782664)
What exactly are the "multitude of drawbacks", that basic CRUD pages suffer from?
Re:You don't need that CORS request by tekknik on Monday January 03, 2022 @08:55PM (#29790154)
Im not the OP and not sure about multitude but one problem for a successful app is bandwidth usage from transferring redundant chunks of HTML, and potentially JS and CSS
Re:You don't need that CORS request by southerntofu on Tuesday January 04, 2022 @07:09AM (#29793940)
Assets like JS/CSS can be cached, and unless you're doing something very convoluted HTML overhead should be pretty low. I mean HTML was standardized in the 90s when we had <100Kb/s (not KB/s) bandwidth so i understand if you have a "successful app" you're always going to need to deal with scaling, but it's not exactly a problem for most of us and caching reverse proxies are very easy to operate and stable nowadays.
Re:You don't need that CORS request by tekknik on Tuesday January 04, 2022 @11:00AM (#29796214)
So you’ve said that you don’t have this problem because your not a successful app? Or are you denying that there’s duplicate HTML, and sometimes JS and CSS being sent? 100k for 100 users is 10mb and bandwidth is one of the easier ways to save costs.
Re:You don't need that CORS request by acdha on Monday January 03, 2022 @02:27PM (#29785175)
> What? No. Not at all. If you're behind a subpar network, your dynamic HTML web app does not load/refresh/update at all, and your users start to get frustrated because your crappy webpage is broken and fails to even do the most basic things. > > This is not the case with SPAs, and some of the most pressing problems they solve: perceived performance, resilience to faulty network connections, and overall improved UX.

That's the sales pitch but here's what actually happens for the vast majority of time: the user gets frustrated because after 5 minutes the SPA finishes failing to load and all they have a blank page or, if it's a site they visit so frequently that all of its dependencies tree are still in the browser's cache, they get the UI shell but nothing works. As a bonus, the assumption that the megabytes of JavaScript would manage state often means that core web functionality like the back button or reloading do not work so while a CRUD user would be able to hit reload and get the expected result as soon as their network connection improves, the SPA user will have to start over from the beginning.

It is technically possible to build things which work offline but in the real world that doesn't work for most applications for a number of reasons:

1. The app depends on things which need to make network requests — you can give a nicer error page but that's not going to make your users happy.

2. The developers ship updates often enough that cached versions aren't current — e.g. you might have all 50MB of dependencies in the cache but if the user got the HTML referencing different URLs, that doesn't matter.

3. The developers forgot to test that they allow long-term caching or serve-stale on their assets.

4. There's a big difference between being completely offline where the interface status shows down and high latency / packet loss. The most frustrating experience for the users are the latter because things act like they're going to work and if they were doing an activity which changes state it might not be clear whether something succeeded or not. The offline API doesn't work for that and it's almost certain that your SPA doesn't really handle it because:

5. Statistically nobody tests in those degraded conditions so they end up with the Twitter-style SPA where it loads the core of the UI structure but then nothing renders. This is better than a server timeout page only in that it allows you to try to convince the user to be less frustrated.

The reason why this is almost always better for server-side rendering comes down to the increased client footprint of an SPA. With an SPA you're depending on an enormous amount of code to load and run before the user sees anything and there's a lot more that can go wrong in ways you didn't handle, which is why it's so common to learn something is an SPA when you get a “successful” blank page. Servers certainly can have problems but most of the moving parts are under your control so you have better visibility and control, and there's no better way to handle degraded conditions than to depend on them less. If the network is slow, trimming your transfer by 1-2 orders of magnitude is going to do more than almost anything else to improve the user experience.

Re:You don't need that CORS request by southerntofu on Tuesday January 04, 2022 @07:10AM (#29793943)
Thanks! You've summarized my experience with SPAs pretty well. Do you have or know of a detailed blogpost on this topic with concrete examples?
Re:You don't need that CORS request by burnished on Monday January 03, 2022 @12:54PM (#29783796)
Could you link to some of the stuff that you are mentioning, maybe an interesting article if you remember one offhand? I think what you are saying is controversial due to the other child comments, which is intriguing because I think what you are saying is interesting and I am hoping you might point me to a larger discussion on the topic.
Re:You don't need that CORS request by lwansbrough on Monday January 03, 2022 @12:58PM (#29783850)
Caching via service workers and the app manifest would be two places to start.
Re:You don't need that CORS request by Spivak on Monday January 03, 2022 @10:27AM (#29781645)
Wait what? Other than "the client blocks JS" which is niche beyond niche the SPA is the one that actually performs better with a spotty network. Fully offline or "occasionally connected" is half the reason to use an SPA. Just as an example once downloaded FB messenger is fully functional over an unreliable network.
Re:You don't need that CORS request by marcosdumay on Monday January 03, 2022 @12:01PM (#29782954)
Hum... I have never seen a SPA perform well with a spotty network.

Yeah, I get what you are trying to get, that an SPA can retry failures, prioritize resources better, reload less data... They just never do that competently, as it is a shitload of work, and the "once downloaded" part is irrelevant, because people only ever load a couple of pages on most sites visits.

Re:You don't need that CORS request by southerntofu on Tuesday January 04, 2022 @07:16AM (#29793968)
Did you try it? Try with 256Kb/s and 20% packet loss (and if your networking tooling allows it, bursts of >1s downtime every 20s) and tell me which one performs better. Yes that's actual conditions in which many people access the Internet in 2021 whether it's on cellular or crappy xDSL.

I've yet to see a single SPA that can deal with such conditions, while native HTML/CSS will work like a breeze in any web browser. For bonus points, browser UI can tell you which requests take a long time and/or refresh any page while maintaining a cache, something most SPAs are really bad at doing, and you get SEO/interoperability for free due to your markup being a curl call away from any client.

Re:You don't need that CORS request by cbm-vic-20 on Monday January 03, 2022 @09:50AM (#29781286)
And the thin/thick client/server wheel continues to turn.
Re:You don't need that CORS request by rattlesnakedave on Monday January 03, 2022 @01:22PM (#29784190)
Why does this always come up? Maybe the author does need the SPA. This comment does not seem particularly relevant to the contents of the article.
Re:You don't need that CORS request by lostcolony on Monday January 03, 2022 @01:29PM (#29784309)
Because if you're re-examining your need of CORS and evaluating whether it makes sense to instead host everything from the same host, you can also re-examine your need of an SPA and evaluate whether it makes sense to instead just render everything server side; it'll solve even more problems if you can.
Re:You don't need that CORS request by rattlesnakedave on Monday January 03, 2022 @01:38PM (#29784450)
> it'll solve even more problems

Wow. Why doesn’t everyone do this?

Re:You don't need that CORS request by igammarays on Monday January 03, 2022 @01:47PM (#29784577)
Actually, a lot of people do. Ever heard of Laravel, Django or Ruby or Rails? Outside of the React/JS world, a lot of developers are happy solving real business problems instead of working with hacks that were built on top of browser DOMs.
Re:You don't need that CORS request by lostcolony on Monday January 03, 2022 @03:57PM (#29786766)
I mean, to be a bit more charitable, when you have use cases that require server pushes, the traditional server rendered pages don't work so well, and that is where SPAs make sense. Mind you, a lot of the frameworks for rendering server side have started to include natural ways of handling those updates (Phoenix Liveview for instance being one I'm familiar with), that makes it so you likely don't need an SPA in those situations, but there are still use cases where an SPA may be simpler or may enable a UX that otherwise would not be possible.

But to the apparently snide response to my original comment, while there may be reasons for SPAs, there are also plenty of uses of them that could be more simply done via server side rendering, especially with the place such frameworks have moved towards, in enabling server pushed updates.

Re:You don't need that CORS request by rattlesnakedave on Monday January 03, 2022 @01:50PM (#29784626)
That’s great to hear. Hopefully I can grow up to be one of them some day.
Re:You don't need that CORS request by Nextgrid on Monday January 03, 2022 @11:45PM (#29791437)
Some people's careers are based on JS frameworks and managing (or perpetuating) frontend complexity. How many will voluntarily put themselves out of a job?
Re:You don't need that CORS request by igammarays on Monday January 03, 2022 @01:27PM (#29784280)
CORS is just one more problem from the class of performance problems that only SPAs have. Seems very relevant to me.
Re:You don't need that CORS request by rattlesnakedave on Monday January 03, 2022 @01:34PM (#29784381)
> only SPAs have

That’s a bold claim.

Re:You don't need that CORS request by th5 on Monday January 03, 2022 @10:12AM (#29781498)
I prefer laravel as well but it’s definitely not as snappy as an spa since I have to load a full page of html at each click. What are you doing differently that I should be doing?

Currently, I’m doing a hybrid sometimes where I’ll have jquery do a call inside the page when I want one particular area to be fast.

Re:You don't need that CORS request by speg on Monday January 03, 2022 @11:00AM (#29782070)
Check out htmx. I use it for thing like table pagination.

Server side I check for htmx headers, and if so omit headers/footers are just return the body. htmx then handles the html swap and boom, you’ve just turned the page without reloading the whole page.

Simple and straightforward. I also use a plugin to preload the responses on mouseover in some cases for even more snapiness.

Re:You don't need that CORS request by igammarays on Monday January 03, 2022 @10:20AM (#29781568)
KISS. Keep the HTML minimal and the full page reload is often just as fast as an AJAX call. For the parts that need to be realtime/interactive I use Livewire. Livewire is annoying to work with sometimes, and the author got carried away with that whole AlpineJS nonsense (reinventing the whole problem), and Livewire is still immature, but the basics work well (just keep your Livewire components extremely simple and it works great).
Re:You don't need that CORS request by datavirtue on Monday January 03, 2022 @04:12PM (#29786970)
Yeah, I cant count how many times I have seen SPAs have tons of calls to an endpoint that passes back huge amount of data when the client needed a single property from the response. This can get artificially bad in large companies that require devs to onboard each endpoint through an API exchange/gateway...because they avoid creating new endpoints.
Re:You don't need that CORS request by kroltan on Monday January 03, 2022 @10:44AM (#29781856)
Keep your markup lean, serve styles separately so they can be cached.
Re:You don't need that CORS request by Joeri on Monday January 03, 2022 @10:34AM (#29781727)
Take a look at the tall stack. It abstracts away the js that does partial page updates.

https://tallstack.dev/

Re:You don't need that CORS request by Nextgrid on Monday January 03, 2022 @11:48PM (#29791459)
How long does it take your server to render the page? That would directly translate to client-facing latency. You want that response time to be as low as possible, definitely under 100ms.
Re:You don't need that CORS request by midrus on Monday January 03, 2022 @11:37AM (#29782570)
+1

I find Laravel + Unpoly a great combination.

Re:You don't need that CORS request by antoaravinth on Monday January 03, 2022 @11:23PM (#29791290)
This is exactly, what I wanted the frontend developers to do. Junior developers introduce new library/framework just because it looks "cool to work with", later it becomes a problem, which will then be replaced by another library (its a endless loop these days).
Re:You don't need that CORS request by kansface on Monday January 03, 2022 @03:10PM (#29785976)
No contract between the front and back end is obviously an extremely tight coupling. I’ve seen this end really badly when you have to cleave them after the fact (particularly with embedded JS in server side templating). For a small product without much velocity, I’d be OK with the approach.
Re:You don't need that CORS request by hiitechk on Monday January 03, 2022 @09:59AM (#29781378)
What did you use for your back-end and for spitting out the HTML?
Re:You don't need that CORS request by igammarays on Monday January 03, 2022 @10:14AM (#29781512)
Laravel. I have no particular love for PHP, but Laravel just "gets it right" and understands the needs of a web developer. After years of working with Python/NodeJS (Flask/Express), Laravel was like a key that fit a lock. The ecosystem of paid plugins and services around it are really well built as well.
Re:You don't need that CORS request by midrus on Monday January 03, 2022 @11:41AM (#29782642)
I've always said that frameworks, tools, ecosystem, libraries, community, etc are far, far, far more important than the programming language.

Also, nowadays PHP is not 10 year's ago PHP, same as nowadays's JavaScript is not 10 year's ago JavaScript. They're both "ok" languages to me.

And yes, having used for many years Django, some playing with Rails on the side, and then everything under the sun for Node, I 100% agree Laravel is freaking awesome and I really wish I had discovered it earlier.

Re:You don't need that CORS request by Zenbit_UX on Monday January 03, 2022 @11:28AM (#29782459)
I love when devs blow off SPAs because they think they're geniuses or above JS. You spun up a shitty 1995 style site that every menu on the toolbar triggers a page reload and patted yourself on the back. Congrats on sending the same html and css with every page load, I'm sure your low network speed users love it.

Eureka exclaimed the "full-stack" developer, who needs javascript!?

Re:You don't need that CORS request by Telemakhos on Monday January 03, 2022 @11:55AM (#29782854)
> Congrats on sending the same html and css with every page load, I'm sure your low network speed users love it.

If only browsers could somehow retain the parts of a web page that did not change, like images and css and js, in some sort of local storage or cache.

Re:You don't need that CORS request by ketralnis on Monday January 03, 2022 @12:31PM (#29783419)
You can probably express this without personal attacks
Re:You don't need that CORS request by echelon on Monday January 03, 2022 @11:33AM (#29782520)
The HTML is probably smaller than the JavaScript blob.

If you can get the HTML within the same order of magnitude as JSON itself, then it's perhaps a compelling argument to ditch SPAs. The bandwidth delta would be minimal, and the development overhead would be much less substantial.

Note that this is how the web used to be. Small HTML markup.

We even started baking structured meaning into the HTML (Semantic Web, "Web 3.0") so that documents could be consumed like APIs. But then JSON and the platform giants put an end to p2p web payloads and rich document schemas. That was a mistake.

Re:You don't need that CORS request by midrus on Monday January 03, 2022 @11:33AM (#29782524)
Probably you're not aware yet that there are also "modern ways" to do server side templates/html. Nowadays you have things such as Unpoly, Htmx, Hotwire, Livewire, etc which can be added incrementaly to any traditional MVC applications leading to an incredible reduction in the amount of work necessary to ship something robust if you're a single developer or in a small team.

SPAs can be great for large teams with different skills/profiles, and large companies with a lot of money though.

Re:You don't need that CORS request by gime_tree_fiddy on Monday January 03, 2022 @12:45PM (#29783665)
Unfortunately, this kind of discussion ends up turning into a knife fight these days here.

I tried using HTMX recently for mainly a CRUD app for personal use, with limited dynamic loading. Still felt the need to rely on JS(Jquery) for loading images and triggering refresh on list of items without full page reload[1].

Did a small A/B test from dev POV using Vue.js, as it is one of the more lighter frameworks. Ended up leaning more towards Vue.js, as had to do some non-conventional(from HTMX POV)[1] things for a simple CRUD app not relying on full page loads/refreshes. Hopefully there is another step in this evolution.

Re:You don't need that CORS request by recursivedoubts on Monday January 03, 2022 @07:10PM (#29789011)
would you mind reaching out to let me know where htmx fell down for you?

htmx at bigsky dot software

or you can jump on the discord if that works:

https://htmx.org/discord

thanks for taking a look at htmx

Re:You don't need that CORS request by fasteo on Tuesday January 04, 2022 @05:39AM (#29793398)
You have Cache-Control and Expires headers for this. Old shitty 1995 style I know.
Re:You don't need that CORS request by rattlesnakedave on Monday January 03, 2022 @01:18PM (#29784131)
This is a harsh but correct take. Additionally separating your backend logic into an API makes it easier to write more clients for your service. This benefit can’t be overstated.
Re:You don't need that CORS request by lolinder on Monday January 03, 2022 @02:03PM (#29784807)
If your HTML-generating code interfaces with a clearly-defined internal API, then your JSON API can be just a thin layer that authenticates the user and provides an HTTP front-end to your internal API.

Essentially, your web "client" is now the HTML-generating server-side code instead of a JavaScript app. Other clients are unaffected and can work the same as they otherwise would.

Re:You don't need that CORS request by ryanbrunner on Monday January 03, 2022 @05:55PM (#29788238)
I've never worked with a web application where the requirements of the "customer facing API" and the "drives the web application API" (or the "drives the mobile application API", "drives the internal admin app API", etc.) matched for very long, if ever. Customers will usually need a small subset of the API that your web app does, the authentication will likely be different, you will need to make optimizations in your web app fetching that will be highly tuned to your specific use case, and a whole bunch of other concerns that make the idea of your web application being driven off your public API unrealistic.
Re:You don't need that CORS request by lostcolony on Monday January 03, 2022 @01:32PM (#29784357)
Sure it can. Such as implying "the only way you'd be able to separate your backend logic into an API is if your browser client uses it".
Re:You don't need that CORS request by igammarays on Monday January 03, 2022 @01:41PM (#29784502)
Even if I knew I needed an API and multiple clients with 100% certainty (and most products don't), I would still prefer to build my browser client deeply integrated without separating the backend logic. The benefits of having at least one platform with faster dev speed cannot be overstated.
Re:You don't need that CORS request by rattlesnakedave on Monday January 03, 2022 @01:57PM (#29784736)
Ya, it all really comes down to the problem you’re solving and what makes sense for the task at hand. The point I was trying to get across in my other reply to you is that sometimes the thing that makes the most sense is an SPA (even if it’s less performant, or takes a little longer to build).