Explore all Single Page Application open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Single Page Application

single-spa

v6.0.0-beta.2

elm-spa

6.0.4

community-app

MIFOSX-21.07.01.RELEASE

single-spa-angular

v6.3.0

single-spa-react

v4.6.1

Popular Libraries in Single Page Application

single-spa

by single-spa doticonjavascriptdoticon

star image 9755 doticonNOASSERTION

The router for easy microfrontends

lavas

by lavas-project doticonjavascriptdoticon

star image 1967 doticonMIT

基于 Vue 的 PWA 解决方案,帮助开发者快速搭建 PWA 应用,解决接入 PWA 的各种问题

startup-demo

by designmodo doticoncssdoticon

star image 1279 doticon

Demo Version of Startup Framework

vue-skeleton-webpack-plugin

by lavas-project doticonjavascriptdoticon

star image 863 doticon

Lavas webpack plugin: skeleton solution for PWA webshell

mooa

by phodal doticontypescriptdoticon

star image 765 doticonNOASSERTION

Mooa 是一个为 Angular 服务的微前端框架。A independent-deployment micro-frontend Framework for Angular from single-spa.

flask-vue-spa

by oleg-agapov doticonjavascriptdoticon

star image 678 doticonMIT

Vue.js SPA served over Flask microframework

coexisting-vue-microfrontends

by joeldenning doticonjavascriptdoticon

star image 566 doticonMIT

A repo showing separate vue apps coexisting as microfrontends with single-spa

rails-prelaunch-signup

by RailsApps doticonrubydoticon

star image 449 doticon

An example Rails 3.2 app for a web startup prelaunch site.

single-spa-portal-example

by me-12 doticonjavascriptdoticon

star image 383 doticonMIT

Example project on how to combine multiple SPA's on a single Website

Trending New libraries in Single Page Application

spa

by tj doticongodoticon

star image 91 doticonMIT

Tiny Single Page Application server for Go with `spa` command-line tool.

Vue-Laravel-SPA-Boilerplate

by LaravelDaily doticonphpdoticon

star image 76 doticon

wp5-and-single-spa

by jherr doticonjavascriptdoticon

star image 61 doticonMIT

Single SPA on Federated Modules

qiankun-vue-demo

by issochen doticoncssdoticon

star image 57 doticon

前端微服务 qiankun demo vue

gomodest-starter

by adnaan doticongodoticon

star image 54 doticonMIT

A complex SAAS starter kit using Go, the html/template package, and sprinkles of javascript.

gomodest-template

by adnaan doticonhtmldoticon

star image 52 doticonMIT

A template to build dynamic web apps quickly using Go, html/template and javascript

laravel-sanctum-example

by qirolab doticonphpdoticon

star image 51 doticon

micro-fun

by cagataycali doticonjavascriptdoticon

star image 51 doticonMIT

Micro frontends as Fun with Next.js & module federation

Laravel-Vue-SPA-Vuetify

by LaravelDaily doticonphpdoticon

star image 47 doticon

Top Authors in Single Page Application

1

single-spa

15 Libraries

star icon10826

2

joeldenning

5 Libraries

star icon1018

3

openmrs

5 Libraries

star icon28

4

react-microfrontends

5 Libraries

star icon64

5

linagora

4 Libraries

star icon26

6

OpenPaaS-Suite

4 Libraries

star icon23

7

wangding

3 Libraries

star icon11

8

polyglot-microfrontends

3 Libraries

star icon22

9

vue-microfrontends

3 Libraries

star icon217

10

VolodymyrPerun

3 Libraries

star icon4

1

15 Libraries

star icon10826

2

5 Libraries

star icon1018

3

5 Libraries

star icon28

4

5 Libraries

star icon64

5

4 Libraries

star icon26

6

4 Libraries

star icon23

7

3 Libraries

star icon11

9

3 Libraries

star icon217

10

3 Libraries

star icon4

Trending Kits in Single Page Application

The use of Java SPA libraries is a great way to make your website perform better. Java components are a great way to add functionality to your website. They can be used in any type of application, whether it be a blog or an e-commerce store. The component is made up of both backend and frontend code. The backend code is written in Java while the frontend code is written in JavaScript. Java SPA is a framework that provides a set of libraries to build web applications. It can be used to build single page applications and hybrid applications that integrate with the browser. SPA-Vertx-Angular is a framework for building Single Page Applications (SPAs) with Vertx. It uses AngularJS as a core library for data manipulation, and Vertx for asynchronous communication between client and server components. It's especially suitable for creating large web applications with hundreds of pages, using various web technologies like HTML5, CSS, JavaScript, Grunt/Gulp build system and Bower package manager. SPA-Vertx-Vue is a framework for building Single Page Applications (SPAs) with Vue.js as core library for data manipulation, and Vertx for asynchronous communication between client and server components. The SPA Vertx-vue library is built on top of the Vertx framework, which provides authentication and authorization for web applications. It also has built-in support for common database management tasks such as creating, reading, updating and deleting records. Popular open source Java SPA libraries among developers include:

The use of JavaScript SPA libraries is a must in this new era of Web development. It is an emerging trend which has gained popularity due to its lightweight nature and easy maintenance. SPA frameworks like AngularJS, ReactJS and VueJS have gained popularity because they are extremely customizable and feature rich compared to other technologies like HTML5 or jQuery. Single-Spa is a JavaScript library for building Single Page Applications (SPA) written by Facebook. prerender-spa-plugin is a plugin for the React development tools that enables webpack to detect when a page has been loaded and preloads it on the server before it is requested by the user. React Snap is a small set of React components that you can use to create your first single page application. Full list of the best open source JavaScript SPA libraries are given below.

Developers can use any web application framework to build their SPA applications in Python. The most popular frameworks are Django and Flask, but there are many other options available as well. You can also choose from a variety of different backend services such as Amazon AWS, Heroku or Google Cloud Platform to power your SPA application. With the increasing number of web applications, the need for a better way to build and manage applications has increased. This is why we've seen the rise of SPA frameworks like AngularJS and React. These frameworks make it easier to build web apps that can be viewed in a browser and have an interactive user interface. Flask is a microframework for Python, while Pyramid and Pyramid are both web applications frameworks. You can use them to create an API. Django is a web framework for Python that is also used for building RESTful APIs. Django Rest Auth provides a simple but powerful way to build REST APIs with Django. It has components and plugins for authentication, views, templates, serialization and other features required by modern web applications.

The Ruby SPA libraries are an interesting way to use JavaScript in a Rails app. They have a lot of advantages over using vanilla JavaScript, and they make it easy to get started with modern web development. The main advantage is that you can use your existing Rails skills to build SPA-like apps without having to learn new tools. For example, if you're familiar with routes and controllers, you can quickly build out a SPAs using the same techniques that you would use for a normal Rails app. jwt_sessions in an easy way to store session data on the server side. This library supports JSON Web Tokens which can be used as session tokens when authenticating users. stirstack is an ORM for storing data in a database and getting it back from the database when needed. Stirstack also supports JSON Web Tokens as an alternative to cookies or sessions. proof is a Ruby gem that helps with testing your code by providing helpful tools such as reporters, matchers and fixtures. It also has an HTTP client that allows you to make requests against a remote service without having to write any code yourself. FlatironJS is a toolkit for building client-side web applications using JavaScript and HTML5 APIs.

The use of PHP SPA libraries like laravel-vue-spa, sanctum, spa-starter-kit, laravel-vuetify-spa-starter make it easier for developers to build web applications. SPA (single page application) is a web app that loads content into the browser from a single HTML file and uses JavaScript to create interactive experiences. Laravel is one of the most popular PHP frameworks in the world. It is used for building web applications using the same codebase and it has been used by many developers for building complex websites and applications. Spa Starter Kit is a collection of Laravel components that can be used to build a SPA. It comes with pre-configured templates, scaffolding tools and a bunch of handy PHP classes. Laravel-vuetify-spa-starter-kit is a framework that helps you to deploy Vue.js applications on Laravel 5.6 and above with npm, webpack and Parse Server. Laravel-vue-spa provides a simple way to setup an SPA using Laravel 5 and Vue.js 2. It also provides the ability to create your own components, mixins and directives. SPA Starter Kit is an opinionated collection of Laravel components that can be used to build SPAs. It comes with pre-configured templates and scaffolding tools, as well as some handy PHP classes.

The use of Go SPA libraries like nico, leaderboard-app, srv, spago, gin-spa makes it easy to build and maintain a single-page application. This can be done by using these libraries to build the frontend part of your application. If you want to create an application with a single page layout and data access layer (DAL), then you need to use one of the above SPA libraries. While there are many benefits of using Go SPA libraries like nico, leaderboard-app, srv, spago and gin-spa in your application development it is important to understand that these libraries are not the only ones available. We can build our own custom Go SPA framework using any of the custom libraries available out there. Nico is the most popular Go library for building web apps. Easily create single page apps powered by Node.js and native iOS and Android components using HTML/JS. Leaderboard-app is a realtime server-rendered React component framework that allows you to build high performance applications that look great on all major browsers without compromising on performance. Spago is the minimalistic yet powerful open source micro-framework for building fast and maintainable servers for your backend. It provides HTTP 1xx error handling out of the box with little effort on your part!

The C# SPA libraries are a great way to build websites and web apps in a short period of time. They allow you to create full-featured applications, including the ability to build mobile apps, in a matter of hours. C# SPA libraries are the new hotness in the world of web development. They allow you to build JavaScript applications using the .NET framework, which is just as powerful as it sounds. SPAs are a great way to build and maintain web applications. They are built on the same principles as regular websites, but they don't require a browser or a server. They also allow developers to focus on their business logic instead of the underlying infrastructure and technology. AspNetCoreSpa is the first SPA library that was developed for ASP.NET Core and .NET Standard 2.0. The AspNetCoreSpa library is built in C#, which means it can be used with .NET Core and ASP.NET Core projects. We will need to create a new folder called AspNetCoreSpa in our project. It provides a unified interface to create rich, responsive single-page applications. Aspnet-core-react-template is a set of React components that are integrated into ASP.NET Core MVC projects. They provide an easy way to build modular, testable views in your apps using JSX and React.js syntax. Butterfly Server is a simple to use server framework built on top of WCF, Web API and ASP.NET Core that allows you to build high performance RESTful web services without writing a lot of code.

Trending Discussions on Single Page Application

How to use dynamic meta tags in react single page application?

.htaccess Open main page if file or folder doesn't exist, but keep URL + URL Routing

Is it ok to send gtag('event', 'page_view') on button click

nginx - Serve multiple roots for different single page applications

Can I use the same domain to proxy two different hosts?

Flutter web 404 Not Found

How to read cookies in Elm?

How to change scrollbar when using Tailwind (next.js/react)

Can I change the status code used for the NotFoundPage in google cloud storage?

How to automatically convert CSRF Tokens to HTTP request headers in Elm?

QUESTION

How to use dynamic meta tags in react single page application?

Asked 2022-Mar-18 at 13:49

I am using react.js for Single Page Applications. routing codes are inside the src --> routes.js I have referred many pages for this one of the pages is https://blog.logrocket.com/adding-dynamic-meta-tags-react-app-without-ssr/ but I don't know where to implement this. I have done exactly what they mentioned but normally we are using "npm start" to run the front-end. even after doing " npm run server" it's showing listening on port 3000. but meta tag values are still like this "title_" .

please refer to any ideology to implement this.

this is the folder structure i have use

ANSWER

Answered 2022-Mar-18 at 13:49

We can use a react helmet to change the meta content dynamically on each page. In my case, I use the helmet on my header , because all the pages on the site have a header. from the header, we can change the meta content dynamically.

https://www.npmjs.com/package/react-helmet

1render(){
2return(<>
3 <Helmet>
4<title>{this.state.metaContent.meta_title}</title>
5<meta name="title" content={"Your dynamic content"} />
6<meta name="description" content={"Your dynamic content"} />
7</Helmet>
8//your content
9</>)}
10

Source https://stackoverflow.com/questions/70242989

QUESTION

.htaccess Open main page if file or folder doesn't exist, but keep URL + URL Routing

Asked 2022-Mar-11 at 01:39

I read through a lot of similar topics, but didn't find the right answer, so please help me.

Let's say the user types in a non-existing sub directory to my webpage:

1www.example.com/subpage-1
2

What I want to achieve:

I want my mainpage (www.example.com - actually with hidden index.html) to open, but keep the URL unchanged with the non-existing subpage (www.example.com/subpage-1).

The reason why I need it: I have the website only with the main site (index.html), and everything is controlled via JavaScript dynamically.

I want to introduce sub pages - but I want to use only my main index.html site with JS to control it. (Just like a single page application.)

So when the user enters the URL www.example.com/subpage-1, my main site opens, but since the URL is kept unchanged, the JS script can check the URL, see, that subpage-1 is requested, and generate the right content for it (if subpage-1 is supported, of course).

Also that could be a SEO-friendly solution, since I could provide Google a sitemap with the available subpages as well - however everything would be controlled via the same index.html and JS.

How can I achieve it?

What I found so far:

1www.example.com/subpage-1
2RewriteCond %{REQUEST_FILENAME} !-d
3RewriteCond %{REQUEST_FILENAME} !-f
4RewriteRule ^(.+)$ index.html?url=$1 [QSA,L]
5

My problem with this is that it opens the main page every time, I can't find the query (?url=) anywhere, so I can't use it.


Also a problem what I don't know how to handle: Let's say the user enters www.example.com/subpage-1 and it's working fine since my JS script handles "subpage-1".

But what if

1www.example.com/subpage-1
2RewriteCond %{REQUEST_FILENAME} !-d
3RewriteCond %{REQUEST_FILENAME} !-f
4RewriteRule ^(.+)$ index.html?url=$1 [QSA,L]
5www.example.com/non-existing-subpage 
6

is entered? With the solution above it would open the main page again, but JS can't load any content for it. I still want 404 for all of the non existing subpages. How can I achieve it?

ANSWER

Answered 2022-Mar-11 at 01:39
1www.example.com/subpage-1
2RewriteCond %{REQUEST_FILENAME} !-d
3RewriteCond %{REQUEST_FILENAME} !-f
4RewriteRule ^(.+)$ index.html?url=$1 [QSA,L]
5www.example.com/non-existing-subpage 
6RewriteCond %{REQUEST_FILENAME} !-d
7RewriteCond %{REQUEST_FILENAME} !-f
8RewriteRule ^(.+)$ index.html?url=$1 [QSA,L]
9

My problem with this that however it opens the main page every time, I can't find the query (?url=) anywhere, so I can't use it.

This is an internal rewrite on the server. Consequently, the url URL parameter (present only on the internal rewrite) is only available to a server-side script, not client-side JavaScript. The browser/client only sees the response from the server - it is not aware of what file produced that response. However, client-side JavaScript can see what is present in the browser's address bar, which is accessible via the window.location object.

So, you can instead simplify the RewriteRule directive:

1www.example.com/subpage-1
2RewriteCond %{REQUEST_FILENAME} !-d
3RewriteCond %{REQUEST_FILENAME} !-f
4RewriteRule ^(.+)$ index.html?url=$1 [QSA,L]
5www.example.com/non-existing-subpage 
6RewriteCond %{REQUEST_FILENAME} !-d
7RewriteCond %{REQUEST_FILENAME} !-f
8RewriteRule ^(.+)$ index.html?url=$1 [QSA,L]
9RewriteRule . index.html [L]
10

And in your JS you can read the requested URL-path from the window.location.pathname property. For example, if you request example.com/foo then the pathname property contains /foo (with a slash prefix) for you to act on accordingly in your script.

I still want 404 for all of the non existing subpages. How can I achieve it?

You can't if you are only using client-side JavaScript. A "404 Not Found" status is an HTTP response sent from the server.

The best you can do in client-side JS is to display what looks-like a "404 Not Found" message to the user and make sure you have a robots meta tag that prevents indexing. But this is still served with a 200 OK HTTP status. Search engines (ie. Google) will likely see this as a soft-404 (ie. a page that looks like a 404, but is served with a 200 OK status).

If you want to serve a 404 HTTP response status then the server would need to be aware of which are valid/invalid URLs.

Source https://stackoverflow.com/questions/71427248

QUESTION

Is it ok to send gtag('event', 'page_view') on button click

Asked 2022-Jan-31 at 19:26

I have a website which had 5 screens but now due to customers demand we are converting them to a Single page on which each screen is displayed on scroll-like all 5 screens are showing on one page with scroll, so we had page view for each screen on old version but now because of single page application, how should I send pageview data to google analytics on each section view?The image shows how before the new work and after the new work screens are displaying.

ANSWER

Answered 2022-Jan-31 at 19:26

This is more of a design question. It's completely up to the person who uses the data. A pageview is not only a metric, it sets the page dimension that is then being used in all events before the next pageview overwrites it. Therefore, when you fire a pageview, you have to make sure the dp/dl dimensions of those pageviews are actually different and indicate what pseudo page users navigate to.

If those pseudo pages have tracked activity on them, then yes, we probably want to set the page for them. But that shouldn't be on button click. Because if the page is scrollable, then now a user can just scroll to our page and get to it efficiently with no button click.

Using pageviews like that is tricky, it entails quite a lot of development. In most cases, simple events suffice, but again, depends on the analyst who consumes the data downstream.

Source https://stackoverflow.com/questions/70923276

QUESTION

nginx - Serve multiple roots for different single page applications

Asked 2022-Jan-26 at 17:57

I'm trying to serve two different versions of a single page application - one, built with a brand new, shiny JS framework, and another built with an older, crummier JS framework. All of the important features and functionality are in the new SPA, and all the non-critical in the older SPA and are in the midst of being ported over.

With this in mind, I'm trying to make the older SPA available via a path, e.g. /old-app.

The new app resides in /www/new-app. The old app resides in /www/old-app.

This is what I have tried:

1server {
2  listen 443;
3
4  root /www/new-app;
5  index index.html;
6
7  location / { # default to new app
8    try_files $uri @prerender;
9  }
10
11  location /old-app {
12    root /www/old-app; # I have also tried *alias* instead of *root* here
13    index index.html;
14    try_files $uri @prerender;
15  }
16
17  location @prerender {
18    set $prerender = 0;
19
20    # a bunch of rules for prerender from here: https://gist.github.com/thoop/8165802
21
22    if ($prerender = 1) {
23      proxy_pass http://127.0.0.1:8080/$scheme://$host$request_uri;
24    }
25
26    if ($prerender = 0) {
27      rewrite .* /index.html break;
28    }
29  }
30}
31

The above returns a 200 OK for https://www.domain.example/old-app/<route>, but the page served is not /www/old-app/index.html. Instead, the file served is from /www/new-app/index.html with a blank page, presumably because the new SPA does not understand the provided /<route>, which only the old SPA understands.

ANSWER

Answered 2022-Jan-26 at 10:33

Two things are wrong here.

1server {
2  listen 443;
3
4  root /www/new-app;
5  index index.html;
6
7  location / { # default to new app
8    try_files $uri @prerender;
9  }
10
11  location /old-app {
12    root /www/old-app; # I have also tried *alias* instead of *root* here
13    index index.html;
14    try_files $uri @prerender;
15  }
16
17  location @prerender {
18    set $prerender = 0;
19
20    # a bunch of rules for prerender from here: https://gist.github.com/thoop/8165802
21
22    if ($prerender = 1) {
23      proxy_pass http://127.0.0.1:8080/$scheme://$host$request_uri;
24    }
25
26    if ($prerender = 0) {
27      rewrite .* /index.html break;
28    }
29  }
30}
31location /old-app {
32    root /www/old-app;
33

This will look for files at /www/old-app/old-app (see this document for details).

1server {
2  listen 443;
3
4  root /www/new-app;
5  index index.html;
6
7  location / { # default to new app
8    try_files $uri @prerender;
9  }
10
11  location /old-app {
12    root /www/old-app; # I have also tried *alias* instead of *root* here
13    index index.html;
14    try_files $uri @prerender;
15  }
16
17  location @prerender {
18    set $prerender = 0;
19
20    # a bunch of rules for prerender from here: https://gist.github.com/thoop/8165802
21
22    if ($prerender = 1) {
23      proxy_pass http://127.0.0.1:8080/$scheme://$host$request_uri;
24    }
25
26    if ($prerender = 0) {
27      rewrite .* /index.html break;
28    }
29  }
30}
31location /old-app {
32    root /www/old-app;
33try_files $uri @prerender;
34

This sends all of your routes to the location @prerender block, which ends with rewrite .* /index.html break;

There may be a more elegant solution, but you could just add a second "prerender" block, for example location @oldrender which is similar to the original, but ends with rewrite ^ /old-app/index.html last;

For example:

1server {
2  listen 443;
3
4  root /www/new-app;
5  index index.html;
6
7  location / { # default to new app
8    try_files $uri @prerender;
9  }
10
11  location /old-app {
12    root /www/old-app; # I have also tried *alias* instead of *root* here
13    index index.html;
14    try_files $uri @prerender;
15  }
16
17  location @prerender {
18    set $prerender = 0;
19
20    # a bunch of rules for prerender from here: https://gist.github.com/thoop/8165802
21
22    if ($prerender = 1) {
23      proxy_pass http://127.0.0.1:8080/$scheme://$host$request_uri;
24    }
25
26    if ($prerender = 0) {
27      rewrite .* /index.html break;
28    }
29  }
30}
31location /old-app {
32    root /www/old-app;
33try_files $uri @prerender;
34location /old-app {
35    root /www;
36    try_files $uri @oldrender;
37}
38location @oldrender {
39    ...
40        rewrite ^ /old-app/index.html last;
41    ...
42}
43

Notice the root has changed, and you need to use rewrite...last.

Source https://stackoverflow.com/questions/70860204

QUESTION

Can I use the same domain to proxy two different hosts?

Asked 2022-Jan-05 at 13:42

I have a main domain, eg.: mydomain.com.
A Single Page Application: myApp, hosted on: myApp.somehost.com (IP: {ip.of.myapp}).
A WordPress Site: myWP, hosted on: myWP.anotherhost.com (IP: {ip.of.mywp}).

The goal:

  1. mydomain.com should show myWP (this is straight forward, I need an A record in my DNS NameServer, with {ip.of.mywp})
  2. mydomain.com/app should show myApp.

How would you solve the second one? Is there a frontend-proxy service provider or so?

What I tried:

  • Cloudflare CDN: rewriting the hostname is not allowed.
  • Vercel: here I can host static pages (myApp) and proxy certain subpaths. But not the root url! So mydomain.com can't show myWp

What should I do? Please help... Thanks

Note: I'm not planning to move myApp and myWP from their current servers.

ANSWER

Answered 2022-Jan-05 at 13:42

You are correct about rewrite rules not supporting this with Cloudflare, but you can use Cloudflare Workers to act as a proxy. Here is a blog article going over details of one way you could achieve what you are looking for -

https://blog.cloudflare.com/subdomains-vs-subdirectories-improved-seo-part-2/

Here are also a number of other Worker examples that may come in handy -

https://developers.cloudflare.com/workers/examples

Do keep in mind the pricing / limits of free plan if you go this route - https://developers.cloudflare.com/workers/platform/pricing

Source https://stackoverflow.com/questions/70592017

QUESTION

Flutter web 404 Not Found

Asked 2022-Jan-03 at 20:16

Flutter Web after deploy in server 404 will appear I know flutter is single page application so we configure the .htaccess file

1RewriteEngine on
2RewriteCond %{REQUEST_FILENAME}% !-d
3RewriteCond %{REQUEST_FILENAME}% !-f
4RewriteRule . /index.html [L]
5

but I use one static html file render in app so this method is not working ​and also I tried 404.html. No use please help me

ANSWER

Answered 2022-Jan-03 at 20:16
1RewriteEngine on
2RewriteCond %{REQUEST_FILENAME}% !-d
3RewriteCond %{REQUEST_FILENAME}% !-f
4RewriteRule . /index.html [L]
5RewriteCond %{REQUEST_FILENAME}% !-d
6RewriteCond %{REQUEST_FILENAME}% !-f
7

You have an erroneous literal % at the end of the TestString argument, so these negated conditions will always be successful, including when the request is rewritten to /index.html.

These conditions should be written:

1RewriteEngine on
2RewriteCond %{REQUEST_FILENAME}% !-d
3RewriteCond %{REQUEST_FILENAME}% !-f
4RewriteRule . /index.html [L]
5RewriteCond %{REQUEST_FILENAME}% !-d
6RewriteCond %{REQUEST_FILENAME}% !-f
7RewriteCond %{REQUEST_FILENAME} !-d
8RewriteCond %{REQUEST_FILENAME} !-f
9

But note that for requests to the document root to be correctly rewritten you need to ensure that the DirectoryIndex is correctly set. For example:

1RewriteEngine on
2RewriteCond %{REQUEST_FILENAME}% !-d
3RewriteCond %{REQUEST_FILENAME}% !-f
4RewriteRule . /index.html [L]
5RewriteCond %{REQUEST_FILENAME}% !-d
6RewriteCond %{REQUEST_FILENAME}% !-f
7RewriteCond %{REQUEST_FILENAME} !-d
8RewriteCond %{REQUEST_FILENAME} !-f
9DirectoryIndex index.html
10

Source https://stackoverflow.com/questions/70570723

QUESTION

How to read cookies in Elm?

Asked 2021-Dec-24 at 14:06

I've learned in this SO question that there currently is no simple way to turn cookie-based CSRF tokens into HTTP request headers in Elm. Thus, to write a single page application (SPA) that works nicely with a Django Rest Framework backend, I need to manually retrieve the CSRF-Token from the corresponding cookie value.

How do I retrieve a cookie value in Elm? Does Elm provide runtime support for this via some Command? Or do I need to retrieve the cookie using plain JavaScript and provide it to the ELM SPA via a port?

ANSWER

Answered 2021-Dec-05 at 21:16

As of Elm 0.9, you need to use Ports to read the cookie from JavaScript and pass it back to the Elm application.

In my application, I do the following. I define a fetchCsrfToken port that I use from Elm to call a JavaScript function that reads the cookie. That function then triggers a callback to Elm via a csrfTokenReciever port. My Elm application subscribes to that event via subscriptions.

1-- Ports.elm
2
3port fetchCsrfToken : () -&gt; Cmd msg
4port csrfTokenReciever : (String -&gt; msg) -&gt; Sub msg
5
1-- Ports.elm
2
3port fetchCsrfToken : () -&gt; Cmd msg
4port csrfTokenReciever : (String -&gt; msg) -&gt; Sub msg
5-- Main.elm
6
7init : Flags -&gt; Url -&gt; Key -&gt; ( Model, Cmd Msg )
8init flags url key =
9  -- ...
10  (model, Ports.fetchCsrfToken ())
11  
12
13subscriptions : Model -&gt; Sub Msg
14subscriptions model =
15  Ports.csrfTokenReciever GotCsrfToken
16
1-- Ports.elm
2
3port fetchCsrfToken : () -&gt; Cmd msg
4port csrfTokenReciever : (String -&gt; msg) -&gt; Sub msg
5-- Main.elm
6
7init : Flags -&gt; Url -&gt; Key -&gt; ( Model, Cmd Msg )
8init flags url key =
9  -- ...
10  (model, Ports.fetchCsrfToken ())
11  
12
13subscriptions : Model -&gt; Sub Msg
14subscriptions model =
15  Ports.csrfTokenReciever GotCsrfToken
16// index.js
17
18app.ports.fetchCsrfToken.subscribe(function (str) {
19  const value = getCookie('csrftoken')
20  if (value === null) {
21    app.ports.csrfTokenReciever.send('')
22  } else {
23    app.ports.csrfTokenReciever.send(value)
24  }
25})
26

Source https://stackoverflow.com/questions/70218177

QUESTION

How to change scrollbar when using Tailwind (next.js/react)

Asked 2021-Dec-15 at 03:11

I'm using Tailwind (react/next) and struggle to change the way my scrollbar looks.

It's a single page application and I have been trying to create custom CSS to apply to the first div in my index file, like this:

1&lt;div className=&quot;no-scroll&quot;&gt; &lt;&lt;&lt;&lt;&lt;&lt;&lt;--------- Adding custom css here
2      &lt;Head&gt;
3        &lt;title&gt;Oscar Ekstrand&lt;/title&gt;
4        &lt;link rel=&quot;icon&quot; href=&quot;/images/favicon.ico&quot; /&gt;
5    
6      &lt;/Head&gt;
7      
8      &lt;main className=&quot;flex flex-col no-scroll&quot;&gt;
9        &lt;section ref={heroref}&gt;
10          &lt;Hero scrollToContacts={scrollToContacts} /&gt;
11        &lt;/section&gt;
12
13        &lt;section ref={offeringref}&gt;
14          &lt;Offering /&gt;
15        &lt;/section&gt;
16        &lt;section ref={processref}&gt;
17          &lt;WhatIDo /&gt;
18        &lt;/section&gt;
19
20        &lt;section ref={biographyref}&gt;
21          &lt;CvBar /&gt;
22        &lt;/section&gt;
23        &lt;section ref={skillsetref}&gt;
24          &lt;Skillset /&gt;
25        &lt;/section&gt;
26      &lt;/main&gt;
27      &lt;section ref={contactsref}&gt;
28        &lt;Footer /&gt;
29      &lt;/section&gt;
30    &lt;/div&gt;
31

I can get custom CSS classes to work for things like buttons, both with a "plugin-approach" and having a global style sheet. (https://play.tailwindcss.com/zQftpiBCmf)

But I can't understand how to change the look of my scrollbar.

Anyone got an idea?

ANSWER

Answered 2021-Oct-01 at 17:53

Tailwind CSS doesn't provide a built-in way to customise the scrollbar styling. However, you can use the various ::-webkit-scrollbar pseudo-elements to style it.

Tailwind playground link: https://play.tailwindcss.com/5samiwyr4v.

1&lt;div className=&quot;no-scroll&quot;&gt; &lt;&lt;&lt;&lt;&lt;&lt;&lt;--------- Adding custom css here
2      &lt;Head&gt;
3        &lt;title&gt;Oscar Ekstrand&lt;/title&gt;
4        &lt;link rel=&quot;icon&quot; href=&quot;/images/favicon.ico&quot; /&gt;
5    
6      &lt;/Head&gt;
7      
8      &lt;main className=&quot;flex flex-col no-scroll&quot;&gt;
9        &lt;section ref={heroref}&gt;
10          &lt;Hero scrollToContacts={scrollToContacts} /&gt;
11        &lt;/section&gt;
12
13        &lt;section ref={offeringref}&gt;
14          &lt;Offering /&gt;
15        &lt;/section&gt;
16        &lt;section ref={processref}&gt;
17          &lt;WhatIDo /&gt;
18        &lt;/section&gt;
19
20        &lt;section ref={biographyref}&gt;
21          &lt;CvBar /&gt;
22        &lt;/section&gt;
23        &lt;section ref={skillsetref}&gt;
24          &lt;Skillset /&gt;
25        &lt;/section&gt;
26      &lt;/main&gt;
27      &lt;section ref={contactsref}&gt;
28        &lt;Footer /&gt;
29      &lt;/section&gt;
30    &lt;/div&gt;
31.scrollbar::-webkit-scrollbar {
32    width: 20px;
33    height: 20px;
34  }
35
36.scrollbar::-webkit-scrollbar-track {
37    border-radius: 100vh;
38    background: #f7f4ed;
39}
40
41.scrollbar::-webkit-scrollbar-thumb {
42    background: #e0cbcb;
43    border-radius: 100vh;
44    border: 3px solid #f6f7ed;
45}
46
47.scrollbar::-webkit-scrollbar-thumb:hover {
48    background: #c0a0b9;
49}
50

Source https://stackoverflow.com/questions/69400560

QUESTION

Can I change the status code used for the NotFoundPage in google cloud storage?

Asked 2021-Dec-07 at 15:27

It looks like when Google Cloud Storage serves the desired object for a NotFoundPage, it includes the status code 404.

Is there any way to set it so that the content is served with a 200 status? This will make it easier for any single page applications I deploy to the bucket to manage their own deep linking.

ANSWER

Answered 2021-Dec-07 at 15:27

It appears as though this is currently a feature request over at the Google Cloud issue tracker: https://issuetracker.google.com/issues/151212194

I encourage anyone who arrives here to head over there and star the issue and also comment to help get this some priority.

Source https://stackoverflow.com/questions/70250347

QUESTION

How to automatically convert CSRF Tokens to HTTP request headers in Elm?

Asked 2021-Dec-03 at 14:07

I am writing a single page application in Elm to interface with a Django backend. The Django Rest Framework provides a CSRF token in a cookie but expects all requests to contain the token in an HTTP header.

Is there a way to declaratively instruct Elm to return the CSRF token as HTTP header with each request? E.g., along the line how I would configure it in JS/Axios:

1axios.defaults.xsrfCookieName = 'csrftoken'
2axios.defaults.xsrfHeaderName = &quot;X-CSRFTOKEN&quot;
3

There is an old SO question that implies to manually extract the token from the cookie and then use Http.send for each request. That would mean to wrap all HTTP request functions by hand.

ANSWER

Answered 2021-Dec-03 at 14:07

Using version 2.0.0 of the elm/http library, you would need to use request in order to provide headers. It's fairly common for an application to use a customized version of these "base" methods that ask for whatever your environment requires.

1axios.defaults.xsrfCookieName = 'csrftoken'
2axios.defaults.xsrfHeaderName = &quot;X-CSRFTOKEN&quot;
3get httpConfig route tagger decoder =
4    Http.request
5        { method = &quot;GET&quot;
6        , headers = httpConfig.headers
7        , url = httpConfig.baseUrl ++ route
8        , body = Http.emptyBody
9        , expect = Http.expectJson tagger decoder
10        , timeout = Nothing
11        , tracker = Nothing
12        }
13
14post httpConfig route value tagger decoder =
15    Http.request
16        { method = &quot;POST&quot;
17        , headers = httpConfig.headers
18        , url = httpConfig.baseUrl ++ route
19        , body = Http.stringBody &quot;application/vnd.api+json&quot; (Encode.encode 0 value)
20        , expect = Http.expectJson tagger decoder
21        , timeout = Nothing
22        , tracker = Nothing
23        }
24

Source https://stackoverflow.com/questions/70206619

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Single Page Application

Tutorials and Learning Resources are not available at this moment for Single Page Application

Share this Page

share link

Get latest updates on Single Page Application