frontend.ro | source tutorials and a community of developers | Collaboration library
kandi X-RAY | frontend.ro Summary
kandi X-RAY | frontend.ro Summary
FrontEnd.ro is an open-source & community driven initiative to teach FrontEnd development. Read more on the website and please share the news ^^^.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of frontend.ro
frontend.ro Key Features
frontend.ro Examples and Code Snippets
Community Discussions
Trending Discussions on frontend.ro
QUESTION
So I'm trying to deploy my website which works well when in a local environment, but when it is deployed to Cloudfront, it can't seem to access cookies.
My frontend tech stack is as follows: Angular site hosted on S3, cloudfront distribution in front of it, custom domain name with a valid ssl certificate.
When the user navigates to the login page, they can successfully submit the forum, and the server responds with a JWT token in the Set-Cookie
header.
After this though, in the angular site it says that the access-token
cookie does not exist. The strange part here is that on subsequent requests, the access-token
cookie is in fact forwarded back to the backend. (In the image below, the login button was pressed again, so the response cookie is the same as the request cookie.)
I've ensured that HttpOnly
is not set, and that the frontend and backend are both hosted under the same root domain frontend.root.com
and api.root.com
.
Cloudfront has been configured to forward the access-token cookie:
origin request policy (note that it still did not work when I had this set to forward all cookies and not just the access token):
So in my angular site, after the /login
api call resolves, I use the ngx-cookie-service
to check and try to retrieve the cookie.
ANSWER
Answered 2022-Feb-03 at 13:29As you can barely make out in the screenshot the Cookies have the domain set as something starting with a
suggesting that it is api.root.com
, most importantly it is not frontend.root.com
and not root.com
.
The server needs to set the domain of the cookie to root.com
for it to be available to all subdomains of it.
QUESTION
Solution
The solution was found thanks to @Gert B.
Simply add to your Laravel application any virtual host (I added for mine) laravel1.test
How to add Virtual host: Go to C:\Windows\System32\drivers\etc\hosts
add line:
127.0.0.1 laravel1.test (or your virtual host name)
And add this to your vhosts(in case of using xampp) in C:\xampp\apache\conf\extra httpd-vhosts
...ANSWER
Answered 2021-Aug-11 at 13:39Solution
The solution was found thanks to @Gert B.
Simply add to your Laravel application any virtual host (I added for mine) laravel1.test
How to add Virtual host: Go to C:\Windows\System32\drivers\etc\hosts
add line:
127.0.0.1 laravel1.test (or your virtual host name)
And add this to your vhosts(in case of using xampp) in C:\xampp\apache\conf\extra httpd-vhosts
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install frontend.ro
Install all the dependencies by running yarn in the root folder.
Create a .env file in root and fill in the following content
Run yarn dev:client. This will run only the FrontEnd locally and connect you to the development server.
If you want to do server-side work you're gonna need to run the server and MongoDB on your local machine as well. For this to happen you're gonna need to add the following variables inside .env:
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page