You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fastn is pretty powerful, but it can not do everything. Maybe you want to use some library that doesn't exist in fastn, actually right now fastn standard library and ecosystem is really sparse, so most likely you do want this feature. It is also helpful if you already have the backend written and you are moving from React etc to fastn.
You can use sql processor to query database directly from fastn as well, but lets say you really need the backend.
Endpoint is a feature we have that lets you route requests to some backend.
-- import: fastn
-- fastn.package: hello
endpoint: http://127.0.0.1:8001 ;; this is where you Django or other service is running
fastn in the front
We recommend running fastn as the frontend server. fastn should have most of your UI, images etc. If you are using say Heroku, fastn should listen on PORT.
If a route is handled by fastn, say if there is a corresponding file in your fastn package, or if you have configured some dynamic url that matches the route, then fastn will serve it as it normally does.
If the route is not handled by fastn, and endpoint is activated as shown in the code snippet, the route is proxied to the endpoint url, and response returned by the endpoint is sent back to browser.
CORS
This setup allows you to access all URLs, both the ones powered by fastn and ones powered by your backend, from fastn's port. Your JavaScript code, or fastn's http frontend function can refer to path without domain name, eg /foo/, and it will be routed either to fastn or your backend server. This setup prevents you from worrying about CORS issues if you would have directly tried to access your backend from browser.
Migration
This setup can also be used to gradually moved functionality from your existing backend to fastn. If you move to fastn, you do not have to worry about deploying your backend, fastn is a simple CLI, that runs on Windows, Mac and Linux, so it is easier to manage.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
A solution for when you have another backend
fastn
is pretty powerful, but it can not do everything. Maybe you want to use some library that doesn't exist infastn
, actually right nowfastn
standard library and ecosystem is really sparse, so most likely you do want this feature. It is also helpful if you already have the backend written and you are moving from React etc tofastn
.You can use
sql
processor to query database directly fromfastn
as well, but lets say you really need the backend.Endpoint is a feature we have that lets you route requests to some backend.
fastn
in the frontWe recommend running
fastn
as the frontend server.fastn
should have most of your UI, images etc. If you are using say Heroku,fastn
should listen onPORT
.If a route is handled by
fastn
, say if there is a corresponding file in your fastn package, or if you have configured some dynamic url that matches the route, thenfastn
will serve it as it normally does.If the route is not handled by
fastn
, andendpoint
is activated as shown in the code snippet, the route is proxied to the endpoint url, and response returned by the endpoint is sent back to browser.CORS
This setup allows you to access all URLs, both the ones powered by fastn and ones powered by your backend, from fastn's port. Your JavaScript code, or fastn's
http
frontend function can refer to path without domain name, eg/foo/
, and it will be routed either tofastn
or your backend server. This setup prevents you from worrying about CORS issues if you would have directly tried to access your backend from browser.Migration
This setup can also be used to gradually moved functionality from your existing backend to fastn. If you move to fastn, you do not have to worry about deploying your backend,
fastn
is a simple CLI, that runs on Windows, Mac and Linux, so it is easier to manage.Beta Was this translation helpful? Give feedback.
All reactions