How can I access the current server URL from a wasp operation?
In a http request I could do
req.headers.origin
, but how do I get that from an operation?2 Replies
Hi @Noah. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To access the current server URL from a Wasp operation, you can use the
config
object imported from wasp/server
. This object contains a frontendUrl
property that provides the URL of your client (the app's frontend).
Here's how you can access it in your operation:
The frontendUrl
is set automatically by Wasp during development when you run wasp start
. In production, you should set it to your client's URL as the server sees it (considering DNS and proxies).
It's important to note that this is not exactly the same as req.headers.origin
from an HTTP request. The config.frontendUrl
is a predetermined value set for your application, while req.headers.origin
would be the actual origin of a specific incoming request.
If you need to set this value for a deployed application, you can do so using the WASP_WEB_CLIENT_URL
environment variable.
Accessing the configuration provides more details on this topic.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Noah, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?thats the frontend URL, what about server
oh found it,
apiUrl
đź‘Ť