Using Valet to serve two projects on sub domains using proxy - laravel

I have two projects one is API(Laravel APP) and another one is a frontend app(Nuxt APP). I want to serve these projects on the same domain using valet on my local. Problem is that I'm not able to do so as both my subdomains are pointing to the frontend app(Nuxt APP). Following are the steps to reproduce the issue
Step 1:
Here each subdomain has been registered using the following commands and is pointing to the right directory,
valet link api.nuxttodo
valet link app.nuxttodo
Note: At this point, if I access api.nuxttodo.test it do successfully open the API(Laravel App)
Two links(sub-domains) that are generated after running these commands are as follows
Step 2:
After that I have added a proxy for the app.nuxttodo.test domain using the command because my frontend app(Nuxt App) is running on http://localhost:60539
valet proxy app.nuxttodo http://localhost:60539
One proxy is as follows
Problem:
Now issue is that both subdomains are now pointing to the same project. Both api.nuxttodo.test and app.nuxttodo.test URL are now opening the frontend app(Nuxt APP) and I'm not able to access my API(Laravel App) which was accessible before running the proxy.

I'm running the same setup and I only used valet link in the Laravel directory.
For the Frontend project, I use valet proxy.
You should unlink the frontend valet unlink app.nuxttodo as that might be causing the issue.

Related

Openlitespeed 301 Moved Permanently problem

I have a new Openlitespeed server on Ubuntu, I have 2 domains pointing to the same IP,
I tried to make a multidomain server so that www.domain1.com would point to one website and www.domain2.com to another.
I followed this tutorial.
Now when I go to domain1.com:80 it returns "CERR_CONNECTION_TIMED_OUT" and if I look at the network tab it shows:
and redirects me to http://domain1.com:8080/
If I go to domain2.com:80 it's the same but it redirects me to 8088.
Before that, I was hosting two testing pages on 8080 and 8088, but I changed all the settings and can't find what is causing the redirections... (both websites are wordpress)
I managed to resolve this, something inside WordPress was redirecting.
I re-downloaded new WordPress and now it works.

Connect Laravel pretty url and nuxt js

I satarted a project based on a Laravel-Nuxt Starter kit, found it here : https://bestofphp.com/repo/cretueusebiu-laravel-nuxt-php-starter-projects
I connected it to Laragon, so I can have pretty urls and making it work on Apache and MySQL. It works nocely, and when I do npm run start, I can access the website locally on localhost:3000 and it updates. However, if I use the pretty url given by Laragon, example.home, it goes to the index.html in the public server, but it doesn't update, no matter what I do. I tried npm run build, but the public folder isnt updated, the changes I do in the Vue component are only visible in localhost:3000.
What can I do to update the public folder according to the changes I do ?
Thank you !

When I use ngrok to load my Laravel app , it only displays basic html and no css

The website my groupmates and I are working on is only locally available on my laptop. I want them to be able to open the website from their own homes, so that my frontend-focused members may edit and view the changes in the website right there and then. I also want my other group members to be able to test the website.
With all the ways I've tried to make our laravel app temporarily publically available through ngrok, they only show the basic HTML. No CSS and javascript.
First was from: https://vanrossum.dev/5-using-ngrok-with-laravel
which involved adding this in the app's AppServiceProvider.php:
public function boot(\Illuminate\Http\Request $request)
{
if (!empty( env('NGROK_URL') ) && $request->server->has('HTTP_X_ORIGINAL_HOST')) {
$this->app['url']->forceRootUrl(env('NGROK_URL'));
}
// other code
}
, running this on ngrok,
ngrok http -host-header=rewrite laravel-site.test:80
adding the received url to the .env file as NGROK_URL: url and then clearing all app caches after
Result: No CSS or js
Second way involved exposing port 9000 though ngrok, and running php artisan serve --port=9000 on my laravel app. (https://www.youtube.com/watch?v=s8efVe5c1Xg) Same thing, no CSS and js.
I also tried what's mentioned here: NGrok and Laravel
But it only loaded the XAMPP Welcome Page
Our CSS and js are mixed with CSS and js files linked using asset() and the use of CDNs.
What should I do to be able to share the website with my groupmates?
I just had to follow this article to the tee:
https://www.jobsity.com/blog/how-run-ngrok-test-share-your-local-development
Open your gitbash terminal in VSCode with your project added in the workspace. (To be sure make sure the path indicated in the gitbash terminal is your project's path)
Turn on artisan server by typing
php artisan serve
This will be using 127.0.0.1 instead of localhost (default).
Leave the console and the artisan server process running. This is the Webserver listening for requests.
Run ngrok, type
ngrok http 8000
A forwarding link will appear similar to the one here: (Note that the forwarding link will be different for you)
Tunnel Status online
Version 1.7/1.6
Forwarding http://284abb77.ngrok.com -> 127.0.0.1:8000
Copy the http link and send it to anyone you want to access the website for development or testing reasons.
(Copying the https link will lead to HTML-only pages with no css/js)
Well this error occurs because in some parts of your css or bootstrap the links are as http and what you need to do is force them to change into https and its pretty simple all you have to do is
1: Go to App->Providers->AppServiceProvider
2: Inside the Register Function write this down
if (env(key: 'APP_ENV') !=='local') {
URL::forceScheme(scheme:'https');
}
3: Reload your website and youre good to go 😉
I just added a new meta tag to app.blade.php:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

Route is not working when I access laravel application through localhost

I have a laravel project and I can access this application through virtual server (tracking.com) locally. When I run through virtual server all the routes are working perfectly. But when I access the application through localhost (localhost/tracking/public) routes are not working except home page.
Home Route
Route::get('/', 'DashboardController#info')->middleware('auth');
Non-working routes
Route::resource('depot', 'DepotsController')->middleware('auth')
All routes are working well with virtual server. With virtual server both routes are working home page(tracking.com) and depots page (tracking.com/depot).
but with localhost only (localhost/tracking/public) is working and (localhost/depot) is not working.
There are three solutions to this issue -
1) If you have Apache or Nginx installed, configure your vhost to point to /public/ directly
2) Use Laravel Homestead
3) Navigate to your project-folder/ within your terminal and run php artisan serve, you can now browse to http://localhost:8000 directly in your browser
Ref: If you are going with the first approach - Click here
use php artisan serve and navigate to 127.0.0.1:8000 from they all the routes will work

Why am I getting broken access to layouts.app (for lavravel app) on heroku hosting but not on localhost?

I am a student and have created my first Laravel App (A blog app). I have a layout/master view created named app.blade.php in resources/views/layouts folder.
I am using laravel 5.6.
It works perfectly on localhost but not on heroku hosting.
Here is my project structure
Here is my code in home.blade.php
Heroku hosting error screen below
Localhost view
clueless about this problem. I need your support.
EDIT
I solved the problem. I am on a windows system while hosting on a linux platform. So my sweet innocent windows was not updating the "Layouts" on server with "layouts".
But I am with another problem
Regards,
Arpan
but loading /login /register correctly
Now this doesn't end here,
when I type /login with the url it gives me
Now I observe that when i click the link it shows me Not secure connection and displays properly but when typing there is https but not displayed correctly.
Please help me analyse and figure out the issue.
Github repo link : https://github.com/ArpanKIIT2017/blog4b/
Its because the app was unable to find the file. But everything looks good. can you check if the file exists on remote server.
what are you using to push the files to remote server?.
try running
php artisan view:clear
on both local and heroku
Actually Heroku doesn't support SSL in free tier. So https actually won't work.
Finnaly migrated my app to postgre sql.
Problem mainly was due to the uppercase and lowercase representation of "Layouts".
So my app is Up and Running only with one problem that is heroku doesn't support file uploads. It is not storing any file upload. Searching solution for that but not related to this post.
Thank You

Resources