DELAPARRA
Index
Color
NL
Category: HTTP headers

Location

Explained by Updated

What is Location?

Location: Where the client should redirect (3xx) or find a newly-created resource (201). The Location header tells the client where to go next. With a redirect, such as 301 or 302, it holds the new URL. With 201 Created, it points to the newly created resource, such as /api/orders/42. Browsers follow redirect locations automatically. API clients can use the location after a create request to fetch or link to the new item without guessing its URL.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Location

What should you keep in mind with Location?

Be careful with redirects based on user input, such as a ?next= parameter after login. If you redirect to whatever URL is given, attackers can send people from your trusted domain to a phishing site. Only allow relative paths or a fixed list of domains. Frameworks like Laravel offer helpers such as redirect()->intended() that handle this safely.

What does an example of Location look like?

Location: /api/users/42

At a glance

CategoryHTTP headers
Explained by
Updated

More HTTP headers terms

All terms starting with L

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.