Best approach for javascript client

We have a ServiceStack API that requires authentication and I was trying to start a frontend project without the server side part, what is the recommended flow?

I’m trying to avoid having a C# page that actually authenticates and then serves as a proxy between the frontend part and the API service.

But in javascript, I will always need to show the credentials upon authentication, though I can make the API to answer to only an IP Address or even “locally” as it will be in the same server…

What should I start looking in order to create my admin frontend that will get data from a ServiceStack API?
Just gathering the best ideas so I don’t hit a wall or two in the middle of the project had have to redo it :frowning:

I’m really struggling to understand what you’re asking in all these questions…

How can you require authentication without the server side? What are you authenticating against?

Are you talking about Razor here, you don’t want to use Razor you just want to use static html, is that the question?

I don’t know what this means either. I’m trying to figure out what JavaScript has to do with needing to show the credentials (Username/Password?), I’m really confused what’s being asked here or what the goal you’re trying to achieve.

Maybe if you compare what you’re trying to do against something real your goals would become clearer. Can you refer to an Live Demo Example that’s close to what you’re after and explain what you want to do differently?

E.g. The ReactChat example is a Single Page App that just uses a static default.html and also supports multiple authentication options and the client is completely written in TypeScript/React. Is this close to what you’re asking? If not what did you want to do differently?

darn, sorry about all the confusion…
trying to say a lot so all points are covered, ending up saying to much :confused:

We have a ServiceStack API that requires authentication and I was trying to start a frontend project without the server side part

I have an api.domain.com and now I want to develop a frontend in domain.com that consumes the api, but without server side code (ASP.NET), just pure whatever-javascript-framework

Are you talking about Razor here, you don’t want to use Razor you just want to use static html, is that the question?

I’m trying to avoid compiled/scripting code (Error: ASP.net | The ASP.NET Site…)

I don’t know what this means either. I’m trying to figure out what JavaScript has to do with needing to show the credentials (Username/Password?), I’m really confused what’s being asked here or what the goal you’re trying to achieve.

simply: Is there a way to develop a frontend that consumes an authenticated API (so we need, prior to any call, do api.domain.com/auth) in pure javascript-whatever-framework :smile:

just trying to avoid ASP.NET all along…

You’re going to run into CORS issues if you try to host the API and static website on different domains.

But the React Chat may be pretty close to what you’re after, the client app itself doesn’t have any coupling with the Server Web Application, i.e. it’s a TypeScript / React project that compiles down to a static default.html + .js library, it could just as easily be your JS fx of choice. But it does benefit from being deployed together as a single WebDeploy package.

If you want to run on different domains you’ll need to enable CORS, but otherwise it should be the same - use Ajax to communicate with the backend APIs.

1 Like