I created a simple User
resource class, using artisan make:resource
. I uploaded my website to a production environment, and changed the .env
file accordingly, and APP_URL
is now including https
. But when I make an ajax request in order to get this resource (through a proper controller of course, and with data retrieved from the database), the links attached to it (meta, links) are prefixed with http
. That's starting to make a trouble since ajax requests from https
to http
resulting blocked:mixed-content
error in the browser. How can I force resource to return links prefixed with https
? Why isn't it happens automatically?
Asked
Active
Viewed 33 times
0

Itzhak Avraham
- 101
- 1
-
1`the links attached to it` - what does that mean? `when I make an ajax request` - how are you making that AJAX request? Show us the code you are using. Please read [how to ask](https://stackoverflow.com/questions/how-to-ask), and how to create a [minimal, complete, and verifiable example](https://stackoverflow.com/help/mcve). – Don't Panic Jul 10 '20 at 00:24
-
Show us a sample of how you are assigning the data in your Resource, are you using `asset()`, `url()`, or something else? As by default a Resource uses the model's `toArray()` method. – Azeame Jul 10 '20 at 01:20
-
@Don'tPanic Where you are using pagination, Laravel generates links for you, that contains the next/previous page and more. See here: https://laravel.com/docs/7.x/eloquent-resources#pagination – Itzhak Avraham Jul 10 '20 at 09:51
-
@Azeame see comment above. – Itzhak Avraham Jul 10 '20 at 09:51
-
@Don'tPanic Thank you very much! Actually, just when you asked me what links am I talking about, I realized that they appear only when using pagination. Before you asked, I never tried to add "pagination" to my google search. – Itzhak Avraham Jul 10 '20 at 10:17
-
1Glad you solved it. There's a famous process of [explaining the problem to a duck](https://blog.codinghorror.com/rubber-duck-problem-solving/). It's a good habit to get into before or as you are writing up a question - you might solve the problem before you actually post it. Even if not, it should be easy for others to help without needing further input. Anyway, I suggest closing this as a dup of the linked question, if that was the answer. – Don't Panic Jul 10 '20 at 10:27