-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaling out #14
Comments
You can adjust it here:
|
@JordanMarr Thank you! How do I set specific virtualPath per env? Do you have pointers where to set in some build time? Also, do you know if the Lit components are SEO friendly or do we need to implement SSR? |
I have used environment variables before, but that was using webpack. I’m not sure about how to set it up with vite. Let me know if you figure it out. |
Curious, have you ever used your template to some deployed running environment? |
Yes, I have an app deployed that runs in an Azure app service. |
Are the frontend deployed somewhere else as static hosting or it's bundled together in Azure app service? |
I just bundled the front end and deployed it as part of the WebApi. |
What if you need to scale out... just scale it along with the backend... or have to perform CDNs on the front end as its own SPA? |
My app is very small, and so I have no need to do that. If you need to scale out, then you should continue down the path of deploying the front end by itself. You will probably need to setup CORS on the backend to allow the front end to connect to it. And, of course, you will need to modify the frontend Server.fs file to point to the backend. Here is some info on vitejs environment variables, but I haven't set this up before, so I'm not sure how helpful it will be. |
Thank you. I'll share what I find. |
If you want a super easy way to do it, you could just change it based on your Debug/Release mode, so it will happen automatically when you build: module WebLit.Server
open System
open Fable.Remoting.Client
open Fable.Core
module Environment =
#if DEBUG
let isDev = true
#else
let isDev = false
#endif
/// Takes path segments and combines them into a valid path
let combine (paths: string list) =
paths
|> List.map (fun path -> List.ofArray (path.Split('/')))
|> List.concat
|> List.filter (fun segment -> not (segment.Contains(".")))
|> List.filter (String.IsNullOrWhiteSpace >> not)
|> String.concat "/"
|> sprintf "/%s"
/// When publishing to IIS, your application most likely runs inside a virtual path (i.e. localhost/SafeApp)
/// every request made to the server will have to account for this virtual path
/// so we get the virtual path from the location
/// `virtualPath` of `http://localhost/SafeApp` -> `/SafeApp/`
let virtualPath : string =
if Environment.isDev
then "/"
else "https://mybackend/api/"
/// Normalized the path taking into account the virtual path of the server
let normalize (path: string) =
combine [ virtualPath; path ]
let normalizeRoutes typeName methodName =
Shared.Api.routerPaths typeName methodName
|> normalize
let api =
Remoting.createApi()
|> Remoting.withRouteBuilder normalizeRoutes
|> Remoting.buildProxy<Shared.Api.IServerApi> |
@JordanMarr Thank you. First timer question: Is there a way to integrate with tailwind CSS with shoe-lace with minimal work or we have to build the web components ourselves with the CSS or find web components lib that are unstyled? I'm thinking to just use raw html with Tailwind CSS and use the |
I've never used Tailwind. I usually just style things myself via CSS or inline styles. |
I apologize if I need a refresher since I just got back from vacation. Assume that I deploy the API to an EC2 instance and deploy the WebLit in S3. Where do I set the settings for WebLit URL calls?
Edit: I'm assuming when I call
Remoting.createApi()
that I setwithBaseUrl
and just pass in different vite.config.js when building depending on which environment?The text was updated successfully, but these errors were encountered: