single-page-application

How to intercept back button in a React SPA using function components and React Router v5

怎甘沉沦 提交于 2020-06-01 05:36:06
问题 I'm working in a SPA in React that doesn't use React Router to create any Routes; I don't need to allow users to navigate to specific pages. (Think multi-page questionnaire, to be filled in sequentially.) But, when users press the back button on the browser , I don't want them to exit the whole app; I want to be able to fire a function when the user presses the back button that simply renders the page as it was before their last selection. (Each page is a component, and they're assembled in

How to refresh in SPA (react, vue)?

不羁的心 提交于 2020-05-31 07:07:49
问题 If the source code or function is changed in the SPA project, you must deploy it to the server again. If the service is deployed, it will continue to load the cached js value unless refreshed. How do I fix this? 回答1: Say all of your SPA code are two files: vendor.js and app.js . To miss the cache when updated, typically what is done is compute hashes of the contents and put it in the file name: vendor.<truncated md5 hash>.js and app.<truncated md5 hash>.js . Each time you build the project

Access variables declared in dynamically imported JavaScript?

喜你入骨 提交于 2020-05-29 10:52:53
问题 I am working on Single Page Architecture (SPA) Web application. I am have implemented functionality to dynamically load different pages of application. This is what my spa.js looks like var spa = { init: async () => { await import('./page.js') spa.data['page'].apply() }, register: (page, data) => { spa.data[page] = data }, data: {}, } window.onload = () => { spa.init() } And this is what my page.js looks like const pageData = { apply: () => { document.body.innerHTML = getMSG() } } function

Access variables declared in dynamically imported JavaScript?

橙三吉。 提交于 2020-05-29 10:52:51
问题 I am working on Single Page Architecture (SPA) Web application. I am have implemented functionality to dynamically load different pages of application. This is what my spa.js looks like var spa = { init: async () => { await import('./page.js') spa.data['page'].apply() }, register: (page, data) => { spa.data[page] = data }, data: {}, } window.onload = () => { spa.init() } And this is what my page.js looks like const pageData = { apply: () => { document.body.innerHTML = getMSG() } } function

Is it insecure to include your login page in your single page application?

佐手、 提交于 2020-05-27 04:19:44
问题 My understanding is that, if you include your login page in your SPA, then the user is receiving all of your code before they're even authenticated. And yet, it seems to be a very common practice. Isn't this incredibly insecure?? Why or why not? 回答1: An SPA would have all the page structures (html and javascript code for the design of pages), but obviously not data. Data would be downloaded in subsequent ajax requests, and that is the point. To download actual data, a user would have to be

Is it insecure to include your login page in your single page application?

孤街醉人 提交于 2020-05-27 04:19:05
问题 My understanding is that, if you include your login page in your SPA, then the user is receiving all of your code before they're even authenticated. And yet, it seems to be a very common practice. Isn't this incredibly insecure?? Why or why not? 回答1: An SPA would have all the page structures (html and javascript code for the design of pages), but obviously not data. Data would be downloaded in subsequent ajax requests, and that is the point. To download actual data, a user would have to be

UIWebView get current URL of SPA (single page application) website

白昼怎懂夜的黑 提交于 2020-05-17 06:06:21
问题 I want to get my UIWebView 's current location when browsing an SPA (single-page-application) website. (Yes, I am intentionally working with UIWebView instead of WKWebView .) I know that there are multiple approaches to getting the current URL, such as: webView.request?.url?.absoluteString webView.request?.mainDocumentURL?.absoluteString webView.stringByEvaluatingJavaScript(from: "window.location") However, for an SPA website, for each of the approaches above, I am getting the initial url,

OAuth2 without Client Secret – Possible Phishing?

眉间皱痕 提交于 2020-05-15 09:43:09
问题 I've been reading the OAuth2 specs over and over, but I can't figure out one thing. Isn't the Authorization Code flow without Client Secret (which is now recommended for single page apps) highly insecure because it can easily be used for phishing? Let me explain: The Client redirects the Resource Owner to the Authorization Server, passing the Redirect URL and Client ID. The Resource Owner approves the request and the Authorization Server redirects him to the given Redirect URL and passes the

ASP.Net core 3.0 (3.1) set PathBase for single page application

爱⌒轻易说出口 提交于 2020-05-14 11:02:08
问题 I have the following asp.net core spa application configured (react-redux template) public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UsePathBase(new PathString("/foo")); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }

Laravel Vue SPA using Sanctum response Unauthorized

£可爱£侵袭症+ 提交于 2020-04-30 07:14:08
问题 The Sanctum Auth system on my local machine works well and I have no errors. But my deployed app is having trouble with authorizing a user. When I login it sends a request to get the user data then redirects. After auth completes you are redirected and the app make a GET request for more data. This GET route is guarded using laravel sanctum. But the backend is not registering that the user has made a successful login attempt so it sends a 401 Unauthorized error. Here is some code... loadUser