angular routing to old asp.net app on the same server - asp.net

So the url for my angular web app is https://devnet/appName/ and when I click a button I want it to go to http://devnet.some.org/appName/page.aspx. now here's the part I need help with, the angular web app is on devnet, testnet and (you guess it) prodnet. depending upon which server the angular app is running from is where I want it to go and find the old app.
https://devnet/appName/route ->
http://devnet.some.org/appName/page.aspx
https://testnet/appName/route ->
http://testnet.some.org/appName/page.aspx
https://prodnet/appName/route ->
http://prodnet.some.org/appName/page.aspx
Notice the change in protocol, the servers are the same as is the appName, but the route and page.aspx will be different.
And yes this is a temporary thing until the angular app is completely complete

The best approach from my POV is to use environments, e.g.:
environment.ts // current one
environment.dev.ts
environment.test.ts
environment.prod.ts
Add corresponding configurations in angular.json (propagate "production" configuration).
Add oldUrl to the environment interface and provide different values for each particular environment.
Import environment to the component where you the redirect button is used and use environment.oldUrl property to construct a proper redirect URL.

Related

Is it possible to build a Static SPA with Next.js that has dynamic routes?

I'm looking to build a static Next.js Single Page App that has dynamic routes, for example: /posts/123. I'd like to do this to:
Be able to host the site anywhere (e.g. S3)
Not need to know the routes at build time (so our APIs can change whenever independently of the Frontend/without requiring a rebuild of the Frontend)
From what I can tell, this should work with:
next build && next export
fallback: true
But the docs suggest that's only for loading/intermediate states.
Can I use some combination of fallback pages/catchall dynamic routes/static generation to get a static single-page app with dynamic routes at runtime? I'm okay with faking the routes using nginx (e.g. /posts/123 -> /index.html).
Edit: the above paragraph doesn't seem possible. From the docs, when using a required catchall route, e.g. [...post].js):
fallback: true is not supported when using next export.

meteor flow-router placement/security

i have a question regarding flow router on meteor.
in the new project structure for meteor, all files are suggested to be kept in the "imports folder" and be imported to either the server folder or client folder. in the tutorials i have seen that use flow router, there was no imports folder and the routes folder with the js file in it was kept right under the project folder. that raises a few questions for me.
where does the flow router code run? on the client? on the server? on both?
if it runs on both, should i leave it outside the imports folder?
if it runs on both/only on the client, what does that mean security-wise? say i don't want a certain user to be able to access a certain page, so in the flow-router action() i write a code that prevents people from reaching where i don't want them, can't they just change this code on the client and bypass the wall?
when referring to a user on the flow-router js file, do i use Meteor.userId() or this.userId?.
i have three functions written inside if(Meteor.isClient) which i copied from a tutorial. the functions are Accounts.onLogin, Accounts.onLogout, FlowRouter.tringgers.enter.
can a user hack through them since they are on the client?
thanks in advance!
From the documentation:
Flow Router is a client side router and it does not have Server Side Routing capability. It has no plans to implement such features either.
so Flow Router runs on the client only and you should put the related code in /imports/startup/client
See (1). Generally, all your code should be placed in the imports directory.
Meteor ensures that any file in any directory named server/ will only be available on the server, and likewise for files in any directory named client/
So if you want to have some code accessible to both the client and the server don't place it in any subdirectories named /client or /server.
Although previously, with Iron Router, authentication was done in the router layer, with Flow Router you should write the auth logic in the template/component layer. Writing code in the flow router action() that prevents users from accessing a page is not a good pattern, according to the creator of Flow Router. Read here for examples and more details.
In server-rendered apps(in the PHP era), if there is an unauthorized access, we can redirect the user to a login page or some other page. In Meteor, or in any single-page app, we can simply show a login screen to the user instead of redirecting them to another page. Or else, we can simply say: "You are not allowed to view this page."
Same as in (3). You shouldn't refer to a user in the router layer.
Any code that runs on the client is not safe from a malicious user.
You may find the following useful:
Meteor guide application structure
Routing Guide for Meteor Apps (with Flow Router)
The example app "Todos", written following the Meteor Guide

Azure deploy slot swap && URLs in config files

I'm sure - it's very common Q, but I'm new with Azure and don't sure how correctly even google this question.
So - here we have some App service with URL site.com. It have "swap" slot, with URL site-staging.com.
Our deployments scheme is:
CI server > deploy to STAGING > check > if ok then swap to PROD
Questions is: in file Web.staging.config - we have:
key="ida:PostLogoutRedirectUri" value="http://site-staging.azurewebsites.net/admin"
But. After "swap" will be done - URL will be changed to "http://site.azurewebsites.net/admin", while in Web.staging.config - it still will use old value - "http://site-staging.azurewebsites.net/admin".
So - after user will open "http://site.azurewebsites.net/admin" and log in - he will be redirected to "http://site-staging.azurewebsites.net/admin" (taken from Web.staging.config), what is obviously wrong direction.
On similar setup in AWS for example - I'd try to use some variables in my "shell-swap-scripts", to determine that staffs and change config values.
But what about Azure's swapping?
Any tips appreciated.
For all settings that change between slots, the best practice is to configure app settings and connection strings from the Azure portal and not using different web.config files. All settings defined in the portal override the values that may be present in the web.config file (for app settings and connection strings).
You can also define specific-slot settings.
See: https://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/#configuration-for-deployment-slots
Hope this helps,
Julien
A simple way to configure Application settings that either switch (or do not switch) depending on the slot setting. Information about configuration can be found in the Azure docs:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/#configuration-for-deployment-slots

Precompiled Single-Page-Apps in Phoenix App

I have a pre-compiled ember.js app (which fronted-js-framework shouldn't matter here), which basically consists of a folder with a index.html file, and a few js/css assets.
I placed this folder under /priv/static in my phoenix app, and tried to get the routing to serve it... without success so far. I'm on phoenix version 0.17.1 (same as 1.0 afaik). I tried the following steps, in that order:
In endpoint.ex, I removed the only: ~w(...) filter.
Implemented a bare minimum controller with a single action to serve the file:
def index(conn, _params) do
redirect conn, to: "/my_app/index.html"
end
added the controller to my routes.ex:
get "/my_app", MyCustomController, :index
None of the above steps worked so far, I only get the Error no route found for GET /my_app/index.html. How could I solve this Issue? I just want to map the URL "/my_app" (or, if nothing else works, "/my_app/index.html") to the path priv/static/my_app/index.html within my phoenix app. Any ideas?
EDIT:
The basic workflow I try to implement is the following:
I have different developers that build some ember.js SPAs in their dedicated folder, located in $phoenix_root/apps/. So I have a developer building $phoenix_root/apps/my_app with ember and ember-cli. This developer uses ember server while developing his app, and has mix phoenix.server running in the background, because the phoenix app itself exposes the required data as an RESTful API.
After each implemented feature, the frontend developer types ember build [...], this task compiles the whole ember.js frontend app into a single folder, with a index.html file and some assets, and moves this folder to $phoenix_root/web/static/assets/my_app. Then phoenix (or, brunch) triggers, and copies this stuff as-is to $phoenix_root/priv/static/my_app, ready to be served like any other asset.
The point is to be able to build a bunch of isolated "frontends" as self-contained packages within a single code base (the phoenix app), while the phoenix app itself has additional (other) stuff to do.
Because the Frontend-Developers auto-generate the SPA everytime, modifying the ever-new index.html file is something I highly want to avoid. Performance-wise it would be the best to just serve these SPAs as the static files they are - they initialize on their own inside the user's browser.
I hope this adds some clarification why I do this.
EDIT 2:
I have a working solution now, see the example repo I created for demonstration purposes: https://github.com/Anonyfox/Phoenix-Example-Multiple-SPA-Frontends
Necessary modifications to the phoenix app:
modify endpoint.ex' Plug.Static to include the SPAs and their assets.
restart mix phoenix.server after this!
Neccessary modifications to the ember.js apps:
add "output-path": "../../web/static/assets/*my_app*/" to .ember-cli, convenience setting to run ember build always with this path
add baseURL: '/*my_app*/' and locationType: 'none' to config/environment.js
rm -rf .git if you want to have all the code versioned within a single project (the purpose of this question)
Your setup should just work. There is only one caveat: every time you change something in lib, you must restart your application.
The only directory that is code reloaded on requests is web. In fact, that's the only difference between lib and web directories. That's why you put long running processes and supervisor in lib, because there is no need to code reload them, and everything else goes in web.
I think easiest way to replace web/templates/layout/app.html.eex with your index html and change assets path inside with <%= static_path(#conn, "/js/app.js") %> helpers to grab your ember app js file from static folder.
Router part:
scope "/", Chat do
pipe_through :browser
get "/", PageController, :index
end
And inside action render conn.

Getting ASP.NET root path to Flex?

I am working on a project that is primarily ASP.NET based. The main project is meant to be deployed to multiple locations for different clients, so one client might be located at website.com/client1 and another at website.com/client2. Within the application, we regularly use the application root operator ~ to get the path to a resource.
We also have a bunch of Flex applications that get deployed in there, and many rely on web services within the ASP.NET application. What I'm after is a way to reference the services relative to the application root. Here's an example of the location of some files for two client deployments:
Client A
website.com/clientA/swf/FlexApplication.swf
website.com/clientA/services/webService.asmx
Client B
website.com/clientB/swf/FlexApplication.swf
website.com/clientB/services/webService.asmx
FlexApplication and webService are both exactly the same, so what I want to do is something like this in the Flex code:
var myService:CustomService = new CustomService(~/services/webService.asmx);
myService.callMethod("Test");
I would like to avoid using relative paths for the usual reasons. Is there a good way to do this or a good way to pass the root url to the flex application from ASP.NET? Thanks in advance.
Its definitely a good idea to avoid relative URL's. The easiest way is to pass the information in via Flash Vars in the HTML embed statement.
Check out Adobe's documentation on using FlashVars with Flex: http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html
Summary:
Add a line to the HTML embed statement like this:
<param name='flashVars' value='serviceRoot=/myserviceRoot'/>
Then access it in Flex via the mx.core.Application.application.parameters accessor
import mx.core.Application;
var parameters:Object = Application.application.parameters;
var serviceRoot:String = parameters['serviceRoot'];
relative to the application root
Flex knows nothing about the application root of a ASP.NET application. The only thing that the Flex app knows is the URL that it is served from. It does not know the URL of the page. Keep in mind that the URL of the page and the URL of the SWF are not the same.
It appears, given your directory structure, that you can use the SWF's URL to get the information you're after.
In a Flex 3 Application, you can get use the url property of the Application tag:
(Application.application as Application).url
In a Flex 4 Spark application, you can also use the url property of the Application Tag, but you have to get it differently:
(FlexGlobals.topLevelApplication as Application).url
Then you can parse it with URLUtils to get your directory structure. Probably store that as a global variable in your Flex application somehow and use it to construct the URL for the service calls you are making to the remote server.
I use this handy little utility to get URL information via javascript inside the .swf.
http://www.flexpasta.com/index.php/category/utility-classes-that-help-you-deal-with-string-numbers-arrays-and-objects-in-actionscript/

Resources