Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more info about favicon.ico. #897

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/advanced/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,33 @@ let file = try FileMiddleware(bundle: .main, publicDirectory: "Public")

Also make sure to use Folder References instead of Groups in Xcode to maintain folder structure in resources after building the application.


The following code from `/Sources/App/routes.swift` can be used with a `favicon.ico` put in `Public/`. The icon of your choosing should be visible on your tab in a browser if you visit the server root resource.

```swift
import Vapor

func routes(_ app: Application) throws {
app.get { req async in
Response(
status: .ok,
headers: ["Content-Type": "text/html"],
body:
"""
<html>
<head>
<link rel="shortcut icon" href="/favicon.ico">
</head>
<body>
It works!
</body>
</html>
"""
)
}
}
```

## CORS Middleware

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served. REST APIs built in Vapor will require a CORS policy in order to safely return requests to modern web browsers.
Expand Down
4 changes: 4 additions & 0 deletions docs/getting-started/folder-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ let fileMiddleware = FileMiddleware(
app.middleware.use(fileMiddleware)
```

If running from Xcode please set the project schema run option working directory.
See [here](xcode.md#custom-working-directory) for more information.


## Sources

This folder contains all of the Swift source files for your project.
Expand Down