First of all, sorry if this question is answered anywhere else, but I could not find the answer I needed so I'll ask again.
I am using laravel to create a REST API which I serve through Docker. Therefore I can reach the API through http://localhost:8888. For example, I have an endpoint /content/fetch/{env_type} which works fine through http://localhost:8888/api/content/fetch/test.
My problem is that I have some images in the (from Laravel root dir) directive /public/images/content/test. I was under the assumption that I would be able to reach these images in my frontend app using <img src="http://localhost:8888/images/content/test/myimage.jpg" /> but this does not work.
I have tried adding public/ before images/... but that did not work either. I also tried the URL to the image in the browser directly, and got 500 Internal Server Error:
Request URL: http://localhost:8888/images/content/test/myimage.jpg
Request Method: GET
Status Code: 500 Internal Server Error
Remote Address: 127.0.0.1:8888
Referrer Policy: no-referrer-when-downgrade
Looking in the laravel log I get this: production.ERROR: Uncaught ErrorException: file_put_contents(/var/www/storage/framework/views/ba2564046cc89e436fb993df6f661f314e4d2efb.php): failed to open stream: Permission denied in /var/www/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
I know what it means but it feels strange that I should have to change the permissions for basically the entire vendor folder.
So my guess is that I am approaching this wrong. Does anyone have an idea how I should do this instead?
Related
I'm trying to create an application that uses the Streamtape API (https://streamtape.com/api#download-getlink) to download a video file. My application run smoothly and perfectly on local development server. However, when I deployed it to live server (AWS), I'm getting a 403 error saying "ASN mismatch / Website: AS14618 Download: AS9299".
I'm trying to figure out the cause of it but no luck. Any idea or fix? I'm using file_get_contents to get te data from JSON response and dynamically add it to link.
https://en.wikipedia.org/wiki/Autonomous_system_(Internet)
TLDR: An ASN identifies a internet network operator. IP address blocks are assigned to ASNs.
This thing seems to be complaining that you're attempting to access it from AS14618 [Amazon] when it is expecting to be accessed from AS9299 [Philippine LDT].
Either you need to get the remote provider to allow access from Amazon, or you need to keep your website inside their approved network.
I would like to publish the file manifest.webmanifest on Laravel Vapor. I've tried to serve it on the root domain (docs):
# vapor.php
...
'serve_assets' => ['manifest.webmanifest'],
...
Vapor handles that route, but throws an exception:
Client error: `GET https://xxxx.cloudfront.net/xxx/manifest.webmanifest` resulted in a `404 Not Found` response:
After further inspection this is logical, because the file is never send to the S3 bucket. It appears that Laravel/VaporCli/AssetFiles filters files like *.webmanifest, manifest.json and mix-manifest.json.
No clue why it does that. Does anyone have a trick to get the job done?
A developer working on Vapor replied and said changing it isn't possible right now because it will be a breaking change. He suggests adding a route that returns the content of the manifest.
I've added this route to my project:
Route::middleware('cache.headers:public;max_age=7200')->get(
'/manifest.webmanifest',
function (): string {
return file_get_contents(public_path('manifest.webmanifest'));
}
)
I install Directus CMS via git clone successful. In the database 15 tables were created. In /config folder my projectkey.php file were created too.
After installation I want to login with my credentials and get the error "Couldn't reach API".
In PHP Error log -> no entry
In Directus log -> no entry
REST calls:
authenticate/ -> Code 200; Response: data/user
projectkey/ -> Code 200; Response: data/api
ping/ -> Code 200; Response: Pong
In a working instance I have seen that in API Call projectkey/ are more properties. For example data/server is missing in my instance.
Does anyone have any idea what this could be?
Version 8.5.X solved my problem
I had the same error and found the solution in the project's corresponding issue:
Check that you're using HTTPS on webservers and local... that is a new requirement added in 8.7.2 due to a cookie policy change by Chrome et al. If it STILL is an issue, please open a new ticket with exact/specific information. Thanks! 👍
Also, just as a reminder, this is a VERY generic error and could shown for several different root causes. More specific error handling/codes is something we're adding in v9.
Enabling SSL fixed it for me.
So I'm creating a route that requires posting. The route is as follows:
my_route:
path: /myroute/login
defaults: { _controller: "MyBundle:Default:login"}
methods: [POST]
So I use postman to hit app_dev.php/myroute/login and I get the correct response that I am looking for, currently the page just returns "hello world". Now when I change postman to just hit app.php/myroute/login I get an error saying:
The server returned a "405 Method Not Allowed".
I'm really confused as to why it says method not allowed so I tailed the prod.log file and got the following:
Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: "No route found for "GET /myroute/login": Method Not Allowed (Allow: POST)"
I'm sending the requests in postman as POST requests but somehow symfony is only seeing them as GET requests. Again I can change the url to app_dev.php/myroute/login and hit send and it works. I thought it was a caching issue so I tried the following to clear the caches:
$ php app/console cache:clear --env=prod --no-debug
This still doesn't clear my problem so I even removed all the files from app/cache/prod as well. I can't find anyone having issues that are similar to this so I'm hoping someone can point me in the right direction. I also thought it might be
After some more digging I discovered what the issue was. So I thought that maybe it was postman that was sending the incorrect method so I googled around for that which lead to this
Postman sending POST as GET
which lead to a question about htaccess files:
Redirect POST htaccess
So first off I set postman to hit app.php/myroute/login and xdebug showed the request method as GET. I moved the .htaccess file and hit the same url and the request method showed up as POST. Instead of hitting that url I moved my .htaccess file back and pointed at just /myroute/login and everything lit up. This was an extremely annoying exercise so I hope that this will save someone else in the future looking for the same problem.
for me the case was my mistake, i.e. i was sending to http instead of https
My live, staging and localhost had a page where it had a map and store finder.
6 months down the line this now does not work and havent touched the code. I have renewed my API key and still no luck. Now i know the API V2 is now not in use and im wondering if i am using the wrong code (confused myself). In my store finder i have this url:
$url = "http://maps.google.co.uk/maps/geo?q=".urlencode($this->input->post('postcode'))."&output=json&key=MYKEY";
Now reading this page ( https://developers.google.com/maps/documentation/geocoding/#JSON ) this has changed but i just cant seem to get a valid url working!
The error i get is: Message: file_get_contents(http://maps.google.co.uk/maps/geo?q=sr3+4as&output=json&key=MYKEY): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
And when i type the url string into google i get this message:
We're sorry...
... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.
If someone can guide me to if my url string is wrong above OR if this is another issue i would appreciate it.
Thanks!
According to the upgrade guide this endpoint URL:
http://maps.google.co.uk/maps/geo
Is using the v2 geocoding API.
Developers switching from v2 may be using a legacy hostname — either maps.google.com, or maps-api-ssl.google.com if
using SSL. You should migrate to the new hostname: maps.googleapis.com.
This URL based on the information in the update guide works for me:
http://maps.googleapis.com/maps/api/geocode/json?address=nebraska&sensor=false