How to access the Wave API in a Digital Ocean Deployment

Solved
btaylor6192

Jul 29th, 2022 07:06 AM

Hello. I cannot seem to access the wave API on a new deployment in Digital Ocean, but I am able to access the site normally. Is there anything else that needs to be done to make that work? I've tried with the standard API port and it times out, and without the port I get an error. Currently I've only tried to access login through the API, and the user does exist and can login through the site as well.

bobbyiliev

Jul 31st, 2022 11:37 PM

Hi there,

There should be no extra steps required to setup the API besides the standard Wave installation steps.

Do you get any errors when you try to access the API? I could suggest also checking your Laravel log for some information.

Best,

Bobby

btaylor6192

Aug 1st, 2022 05:53 AM

So on my local dev machine I would go to Tools -> Compass to check logs. I still have that option locally, but in the DO deployment I do not.

I'm also getting a '405 method not allowed error' in Insomnia when trying to do the API login to that DO instance when I just point to the domain name. When I try to add :8000 to the url, it times out.

bobbyiliev

Aug 1st, 2022 08:14 AM

Hey,

Ah yes, I see what you mean. This is because Laravel Voyager by default disables the access to Compass when your Laravel App is in production mode (eg. when you've set APP_ENV to production in your .env file).

What you could do is just add the following line in your config/voyager.php:

    'compass_in_production' => true,

That way you will be able to access the compass page as normal!

Hope that this helps!

Best,

Bobby

btaylor6192

Aug 1st, 2022 10:18 AM

Can you give more detail where exactly in that file to set it? Also, how would I update the app afterwards to reflect that change?

I did try setting the APP_ENV variable to local, and the wave instance did not like it at all, the site got all messed up until I set it back to production and re-deployed.

Also side question, in searching for answers last week I thought I saw a reference to a discord channel, is there one?

bobbyiliev

Aug 2nd, 2022 02:02 AM

Hi there,

Yes, so when deploying your App to a server, it is best to keep the APP_ENV variable set to production.

All you need to do is to open the config/voyager.php file and at the bottom before the closing ] add the following: 'compass_in_production' => true,.

This will allow you to use compass in production.

Let me know if you have any questions.

I will DM you the link to the Discord server!

Best,

Bobby

btaylor6192

Aug 2nd, 2022 07:15 AM

Thank you! That did indeed allow me to access the logs, looks like I had just put it in the wrong place previously. So now I'm seeing the stack trace when I try to log in through the API, starting with this:

Lcobucci\JWT\Signer\Hmac::createHash(): Argument #2 ($key) must be of type Lcobucci\JWT\Signer\Key, null given,

bobbyiliev

Aug 2nd, 2022 09:18 AM

Best Answer

Hey,

Ah yes, this happens when the JWT_SECRET environment variable is not defined.

You need to set it in your env file and then this should work as normal.

If you don't have one already, you can create a new one with:

php artisan jwt:secret 

Let me know how it goes.

Best,

Bobby

btaylor6192

Aug 2nd, 2022 10:38 AM

That did indeed work! I'm able to interact with the API now, thanks!

Is there a general guide for running Wave in prod? I thought I had seen one a while back but was not able to find it, I figured I was missing something there and turns out that was correct.

bobbyiliev

Aug 3rd, 2022 01:43 AM

Hey there,

Happy to hear that you've got it all working now!

Regarding the deployment, you can think of Wave as a standard Laravel Application. I personally use DigitalOcean + Laravel Forge to automate my deployments to production:

An alternative way to Forge is to use LaraSail which is a script that we've created for the initial server setup:

A good reference guide is the one from the official Laravel docs:

Laravel Deployment

Hope that this helps!

Best,

Bobby

Report
1